Support marshal.dump(x, f) where f is not a real file.

Support ord(b) where b is a 1-byte string.
In zipfile.py, work around bytes being ints instead of chars, sometimes.
This commit is contained in:
Guido van Rossum 2007-04-13 03:31:13 +00:00
parent 84d79ddce2
commit 98f9746740
3 changed files with 27 additions and 6 deletions

View file

@ -348,7 +348,13 @@ class _ZipDecrypter:
def __call__(self, c):
"""Decrypt a single character."""
c = ord(c)
# XXX When this is called with a byte instead of a char, ord()
# isn't needed. Don't die in that case. In the future we should
# just leave this out, once we're always using bytes.
try:
c = ord(c)
except TypeError:
pass
k = self.key2 | 2
c = c ^ (((k * (k^1)) >> 8) & 255)
c = chr(c)