[Python-3000-checkins] r58913 - python/branches/py3k/Lib/io.py python/branches/py3k/Lib/py_compile.py
christian.heimes
python-3000-checkins at python.org
Thu Nov 8 17:34:32 CET 2007
Author: christian.heimes
Date: Thu Nov 8 17:34:32 2007
New Revision: 58913
Modified:
python/branches/py3k/Lib/io.py
python/branches/py3k/Lib/py_compile.py
Log:
Fixed #1403 where compileall and py_compile choked on an encoding header in a py file. Both modules need more unit tests.
Modified: python/branches/py3k/Lib/io.py
==============================================================================
--- python/branches/py3k/Lib/io.py (original)
+++ python/branches/py3k/Lib/io.py Thu Nov 8 17:34:32 2007
@@ -1063,6 +1063,9 @@
else:
encoding = locale.getpreferredencoding()
+ if not isinstance(encoding, str):
+ raise ValueError("invalid encoding: %r" % encoding)
+
self.buffer = buffer
self._encoding = encoding
self._readuniversal = not newline
Modified: python/branches/py3k/Lib/py_compile.py
==============================================================================
--- python/branches/py3k/Lib/py_compile.py (original)
+++ python/branches/py3k/Lib/py_compile.py Thu Nov 8 17:34:32 2007
@@ -88,7 +88,7 @@
break
m = re.match(r".*\bcoding:\s*(\S+)\b", line)
if m:
- return str(m.group(1))
+ return m.group(1).decode("ascii")
return default
finally:
f.close()
More information about the Python-3000-checkins
mailing list