Index: Lib/encodings/punycode.py =================================================================== --- Lib/encodings/punycode.py (revision 82984) +++ Lib/encodings/punycode.py (working copy) @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Codec for the Punicode encoding, as specified in RFC 3492 Written by Martin v. Löwis. Index: Lib/getopt.py =================================================================== --- Lib/getopt.py (revision 82984) +++ Lib/getopt.py (working copy) @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Parser for command line options. This module helps scripts to parse the command line arguments in @@ -20,7 +19,7 @@ # Gerrit Holl moved the string-based exceptions # to class-based exceptions. # -# Peter Åstrand added gnu_getopt(). +# Peter Åstrand added gnu_getopt(). # # TODO for gnu_getopt(): # Index: Lib/inspect.py =================================================================== --- Lib/inspect.py (revision 82984) +++ Lib/inspect.py (working copy) @@ -1,4 +1,3 @@ -# -*- coding: iso-8859-1 -*- """Get useful information from live Python objects. This module encapsulates the interface provided by the internal special Index: Lib/ast.py =================================================================== --- Lib/ast.py (revision 82984) +++ Lib/ast.py (working copy) @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ ast ~~~ Index: Lib/pydoc.py =================================================================== --- Lib/pydoc.py (revision 82984) +++ Lib/pydoc.py (working copy) @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: latin-1 -*- """Generate Python documentation in HTML or text for interactive use. In the Python interpreter, do "from pydoc import help" to provide online Index: Lib/msilib/__init__.py =================================================================== --- Lib/msilib/__init__.py (revision 82984) +++ Lib/msilib/__init__.py (working copy) @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2005 Martin v. Löwis # Licensed to PSF under a Contributor Agreement. from _msi import * Index: Lib/sqlite3/__init__.py =================================================================== --- Lib/sqlite3/__init__.py (revision 82984) +++ Lib/sqlite3/__init__.py (working copy) @@ -1,7 +1,6 @@ -#-*- coding: ISO-8859-1 -*- # pysqlite2/__init__.py: the pysqlite2 package. # -# Copyright (C) 2005 Gerhard Hring +# Copyright (C) 2005 Gerhard Häring # # This file is part of pysqlite. # Index: Lib/sqlite3/dbapi2.py =================================================================== --- Lib/sqlite3/dbapi2.py (revision 82984) +++ Lib/sqlite3/dbapi2.py (working copy) @@ -1,7 +1,7 @@ -#-*- coding: ISO-8859-1 -*- +#-*- coding: utf-8 -*- # pysqlite2/dbapi2.py: the DB-API 2.0 interface # -# Copyright (C) 2004-2005 Gerhard Hring +# Copyright (C) 2004-2005 Gerhard Häring # # This file is part of pysqlite. # Index: Lib/test/test_imp.py =================================================================== --- Lib/test/test_imp.py (revision 82984) +++ Lib/test/test_imp.py (working copy) @@ -5,8 +5,8 @@ import sys import unittest from test import support +import importlib - class LockTests(unittest.TestCase): """Very basic test of import lock functions.""" @@ -42,18 +42,32 @@ "RuntimeError") class ImportTests(unittest.TestCase): + def setUp(self): + mod = importlib.import_module('test.encoded_modules') + self.test_strings = mod.test_strings + self.test_path = mod.__path__ + def test_import_encoded_module(self): + for modname, encoding, teststr in self.test_strings: + mod = importlib.import_module('test.encoded_modules.' + 'module_' + modname) + self.assertEqual(teststr, mod.test) + def test_find_module_encoding(self): - fd = imp.find_module("pydoc")[0] - self.assertEqual(fd.encoding, "iso-8859-1") + for mod, encoding, _ in self.test_strings: + fd = imp.find_module('module_' + mod, self.test_path)[0] + self.assertEqual(fd.encoding, encoding) def test_issue1267(self): - fp, filename, info = imp.find_module("pydoc") - self.assertNotEqual(fp, None) - self.assertEqual(fp.encoding, "iso-8859-1") - self.assertEqual(fp.tell(), 0) - self.assertEqual(fp.readline(), '#!/usr/bin/env python3\n') - fp.close() + for mod, encoding, _ in self.test_strings: + fp, filename, info = imp.find_module('module_' + mod, + self.test_path) + self.assertNotEqual(fp, None) + self.assertEqual(fp.encoding, encoding) + self.assertEqual(fp.tell(), 0) + self.assertEqual(fp.readline(), '# test %s encoding\n' + % encoding) + fp.close() fp, filename, info = imp.find_module("tokenize") self.assertNotEqual(fp, None) Index: Lib/test/encoded_modules/module_iso_8859_1.py =================================================================== --- Lib/test/encoded_modules/module_iso_8859_1.py (revision 0) +++ Lib/test/encoded_modules/module_iso_8859_1.py (revision 0) @@ -0,0 +1,5 @@ +# test iso-8859-1 encoding +# -*- encoding: iso-8859-1 -*- +test = ("Les hommes ont oubli cette vrit, " + "dit le renard. Mais tu ne dois pas l'oublier. Tu deviens " + "responsable pour toujours de ce que tu as apprivois.") Index: Lib/test/encoded_modules/__init__.py =================================================================== --- Lib/test/encoded_modules/__init__.py (revision 0) +++ Lib/test/encoded_modules/__init__.py (revision 0) @@ -0,0 +1,8 @@ +# -*- encoding: utf-8 -*- +# module, encoding, test string +test_strings = ( + ('iso_8859_1', 'iso-8859-1', "Les hommes ont oublié cette vérité, " + "dit le renard. Mais tu ne dois pas l'oublier. Tu deviens " + "responsable pour toujours de ce que tu as apprivoisé."), + ('koi8_r', 'koi8-r', "Познание бесконечности требует бесконечного времени.") +) Index: Lib/test/encoded_modules/module_koi8_r.py =================================================================== --- Lib/test/encoded_modules/module_koi8_r.py (revision 0) +++ Lib/test/encoded_modules/module_koi8_r.py (revision 0) @@ -0,0 +1,3 @@ +# test koi8-r encoding +# -*- encoding: koi8-r -*- +test = " ."