Closed Bug 1644247 Opened 5 years ago Closed 5 years ago

Fix dmd.py with Python 3

Categories

(Core :: DMD, defect)

defect

Tracking

()

RESOLVED DUPLICATE of bug 1668903

People

(Reporter: mccr8, Unassigned)

References

Details

I tried running dmd.py using python3, but it raised this exception:

osx:~/logs/queue/2 % python3 ~/mc/obj-dbg.noindex/dist/bin/dmd.py test.json.gz
Traceback (most recent call last):
File "/Users/andrewmccreight/mc/obj-dbg.noindex/dist/bin/dmd.py", line 923, in <module>
main()
File "/Users/andrewmccreight/mc/obj-dbg.noindex/dist/bin/dmd.py", line 915, in main
digest = getDigestFromFile(args, args.input_file)
File "/Users/andrewmccreight/mc/obj-dbg.noindex/dist/bin/dmd.py", line 267, in getDigestFromFile
fixStackTraces(inputFile, isZipped, opener)
File "/Users/andrewmccreight/mc/obj-dbg.noindex/dist/bin/dmd.py", line 253, in fixStackTraces
tmpFile.write(fix(line))
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/gzip.py", line 251, in write
raise OSError(errno.EBADF, "write() on read-only GzipFile object")
OSError: [Errno 9] write() on read-only GzipFile object

If I do the same thing, except with "python2" instead of "python3" it works. I looked up the documentation for 2.7 and 3.8 (though it looks like this is using 3.7) for tempfile and gzip and I didn't see any obvious reason why this would break.

The gzip documentation says "The default is the mode of fileobj if discernible; otherwise, the default is 'rb'." so maybe "discernibility" changed in Python 3, whatever that means.

Passing in a mode='wb' argument at least fixes that error, though then I hit a different error "memoryview: a bytes-like object is required, not 'str'", but at least that's an error I'd expect from running under Python3.

The severity field is not set for this bug.
:njn, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(n.nethercote)
Severity: N/A → S4
Flags: needinfo?(n.nethercote)
Summary: "write() on read-only GzipFile object" when running dmd.py using Python3 → Fix dmd.py with Python 3

I could land the fix for this particular issue, but it is a tiny patch, so we might as well aggregate more fixes together.

Bug 1668903 has a patch so I will dup this bug to that one.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.