Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r59021:ca4dcce7e9f7
Date: 2012-11-20 23:14 +0100
http://bitbucket.org/pypy/pypy/changeset/ca4dcce7e9f7/
Log: zipimport.get_source() returns a unicode string. Test and fix.
diff --git a/pypy/module/zipimport/interp_zipimport.py
b/pypy/module/zipimport/interp_zipimport.py
--- a/pypy/module/zipimport/interp_zipimport.py
+++ b/pypy/module/zipimport/interp_zipimport.py
@@ -316,10 +316,14 @@
fname = filename + ext
if self.have_modulefile(space, fname):
if not compiled:
- return self.get_data(space, fname)
+ w_data = self.get_data(space, fname)
+ # XXX CPython does not handle the coding cookie either.
+ return space.call_method(w_data, "decode",
+ space.wrap("utf-8"))
else:
found = True
if found:
+ # We have the module, but no source.
return space.w_None
raise operationerrfmt(get_error(space),
"Cannot find source for %s in %s", filename, self.name)
diff --git a/pypy/module/zipimport/test/test_zipimport.py
b/pypy/module/zipimport/test/test_zipimport.py
--- a/pypy/module/zipimport/test/test_zipimport.py
+++ b/pypy/module/zipimport/test/test_zipimport.py
@@ -271,13 +271,13 @@
assert z.get_data(self.zipfile + os.sep + "xxx") == data
assert z.is_package("xx")
assert not z.is_package("yy")
- assert z.get_source("yy") == b'3'
+ assert z.get_source("yy") == '3'
assert z.get_source('uu') is None
raises(ImportError, "z.get_source('zz')")
#assert z.get_code('yy') == py.code.Source('3').compile()
#assert z.get_code('uu') == self.co
assert z.get_code('xx')
- assert z.get_source('xx') == b"5"
+ assert z.get_source('xx') == "5"
assert z.archive == self.zipfile
mod = z.load_module('xx')
assert z.get_filename('xx') == mod.__file__
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit