Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r61241:45cb84f839e7
Date: 2013-02-14 13:57 -0800
http://bitbucket.org/pypy/pypy/changeset/45cb84f839e7/

Log:    we must flush this stream now as streamio's buffering may not have

diff --git a/pypy/module/imp/interp_imp.py b/pypy/module/imp/interp_imp.py
--- a/pypy/module/imp/interp_imp.py
+++ b/pypy/module/imp/interp_imp.py
@@ -78,6 +78,7 @@
             top = stream.readline()
             top += stream.readline()
             stream.seek(0, 0) # reset position
+            stream.flush()
             encoding = pyparse._check_for_encoding(top)
             if encoding is None:
                 encoding = unicodetype.getdefaultencoding(space)
diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -674,6 +674,7 @@
         import encoded
         fd = imp.find_module('line2', encoded.__path__)[0]
         assert fd.encoding == 'iso-8859-1'
+        assert fd.tell() == 0
 
     def test_bad_source_encoding(self):
         import imp
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to