diff options
author | Brett Cannon <bcannon@gmail.com> | 2008-09-04 05:04:25 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2008-09-04 05:04:25 (GMT) |
commit | 8a9583ec5c00384514fe9f5045866ad6ebd2be5a (patch) | |
tree | e360bd182c5c79d8dd3ca9147fce290b9efdda03 /Lib/test/test_imp.py | |
parent | 451e99b393529b45db3b68daaf09925ea863bf1a (diff) | |
download | cpython-8a9583ec5c00384514fe9f5045866ad6ebd2be5a.zip cpython-8a9583ec5c00384514fe9f5045866ad6ebd2be5a.tar.gz cpython-8a9583ec5c00384514fe9f5045866ad6ebd2be5a.tar.bz2 |
PyTokenizer_FindEncoding() always failed because it set the tokenizer state
with only a file pointer when it called fp_setreadl() which expected a file
path. Changed fp_setreadl() to use either a file path or file descriptor
(derived from the file pointer) to fix the issue.
Closes issue 3594.
Reviewed by Antoine Pitrou and Benjamin Peterson.
Diffstat (limited to 'Lib/test/test_imp.py')
-rw-r--r-- | Lib/test/test_imp.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py index e2b9e9a..3a3059e 100644 --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -1,4 +1,5 @@ import imp +import sys import unittest from test import support @@ -59,6 +60,21 @@ class ImportTests(unittest.TestCase): '"""Tokenization help for Python programs.\n') fp.close() + def test_issue3594(self): + temp_mod_name = 'test_imp_helper' + sys.path.insert(0, '.') + try: + with open(temp_mod_name + '.py', 'w') as file: + file.write("# coding: cp1252\nu = 'test.test_imp'\n") + file, filename, info = imp.find_module(temp_mod_name) + file.close() + self.assertEquals(file.encoding, 'cp1252') + finally: + del sys.path[0] + support.unlink(temp_mod_name + '.py') + support.unlink(temp_mod_name + '.pyc') + support.unlink(temp_mod_name + '.pyo') + def test_reload(self): import marshal imp.reload(marshal) |