summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/encodings/__init__.py2
-rw-r--r--Lib/test/test_charmapcodec.py15
-rw-r--r--Misc/NEWS6
3 files changed, 20 insertions, 3 deletions
diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py
index 8a50ac1..01463bc 100644
--- a/Lib/encodings/__init__.py
+++ b/Lib/encodings/__init__.py
@@ -91,7 +91,7 @@ def search_function(encoding):
if not modname:
continue
try:
- mod = __import__(modname,
+ mod = __import__('encodings.' + modname,
globals(), locals(), _import_tail)
except ImportError:
pass
diff --git a/Lib/test/test_charmapcodec.py b/Lib/test/test_charmapcodec.py
index 79d82c1..2866984 100644
--- a/Lib/test/test_charmapcodec.py
+++ b/Lib/test/test_charmapcodec.py
@@ -11,8 +11,19 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
import test.test_support, unittest
-# test codec's full path name (see test/testcodec.py)
-codecname = 'test.testcodec'
+import codecs
+
+# Register a search function which knows about our codec
+def codec_search_function(encoding):
+ if encoding == 'testcodec':
+ from test import testcodec
+ return tuple(testcodec.getregentry())
+ return None
+
+codecs.register(codec_search_function)
+
+# test codec's name (see test/testcodec.py)
+codecname = 'testcodec'
class CharmapCodecTest(unittest.TestCase):
def test_constructorx(self):
diff --git a/Misc/NEWS b/Misc/NEWS
index 078f702..32f6047 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,12 @@ What's New in Python 2.5 alpha 1?
Core and builtins
-----------------
+- Fix the encodings package codec search function to only search
+ inside its own package. Fixes problem reported in patch #1433198.
+
+ Note: Codec packages should implement and register their own
+ codec search function. PEP 100 has the details.
+
- PEP 353: Using ssize_t as the index type.
- Patch #1400181, fix unicode string formatting to not use the locale.