mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
Make test_zipfile pass.
The zipfile module now does all I/O in binary mode using bytes. (Maybe we should support wrapping a TextIOWrapper around it when text mode reading is requested?) Even the password is a bytes array now. Had to fix py_compile.py to use bytes while I was at it. The _struct needed a patch to support bytes, str8 and str for the 's' and 'p' formats.
This commit is contained in:
parent
94ca1c620e
commit
d6ca546091
4 changed files with 177 additions and 146 deletions
|
@ -72,10 +72,10 @@ else:
|
|||
|
||||
def wr_long(f, x):
|
||||
"""Internal; write a 32-bit int to a file in little-endian order."""
|
||||
f.write(chr( x & 0xff))
|
||||
f.write(chr((x >> 8) & 0xff))
|
||||
f.write(chr((x >> 16) & 0xff))
|
||||
f.write(chr((x >> 24) & 0xff))
|
||||
f.write(bytes([x & 0xff,
|
||||
(x >> 8) & 0xff,
|
||||
(x >> 16) & 0xff,
|
||||
(x >> 24) & 0xff]))
|
||||
|
||||
def compile(file, cfile=None, dfile=None, doraise=False):
|
||||
"""Byte-compile one Python source file to Python bytecode.
|
||||
|
@ -133,7 +133,7 @@ def compile(file, cfile=None, dfile=None, doraise=False):
|
|||
if cfile is None:
|
||||
cfile = file + (__debug__ and 'c' or 'o')
|
||||
fc = open(cfile, 'wb')
|
||||
fc.write('\0\0\0\0')
|
||||
fc.write(b'\0\0\0\0')
|
||||
wr_long(fc, timestamp)
|
||||
marshal.dump(codeobject, fc)
|
||||
fc.flush()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue