[pypy-svn] r14894 - pypy/dist/pypy/module/_codecs

arigo at codespeak.net arigo at codespeak.net
Thu Jul 21 22:23:27 CEST 2005


Author: arigo
Date: Thu Jul 21 22:23:26 2005
New Revision: 14894

Modified:
   pypy/dist/pypy/module/_codecs/app_codecs.py
Log:
Minor fix to ensure that encodings is imported even if _codec.register() is called before _codec.lookup().


Modified: pypy/dist/pypy/module/_codecs/app_codecs.py
==============================================================================
--- pypy/dist/pypy/module/_codecs/app_codecs.py	(original)
+++ pypy/dist/pypy/module/_codecs/app_codecs.py	Thu Jul 21 22:23:26 2005
@@ -41,6 +41,7 @@
 codec_search_path = []
 codec_search_cache = {}
 codec_error_registry = {}
+codec_need_encodings = [True]
 
 def codec_register( search_function ):
     """register(search_function)
@@ -63,10 +64,11 @@
     
     result = codec_search_cache.get(encoding,None)
     if not result:
-        if len(codec_search_path) == 0:
+        if codec_need_encodings:
             import encodings
             if len(codec_search_path) == 0:
                 raise LookupError("no codec search functions registered: can't find encoding")
+            del codec_need_encodings[:]
         if not isinstance(encoding,str):
             raise TypeError("Encoding must be a string")
         for search in codec_search_path:
@@ -1607,4 +1609,4 @@
                     p += unichr(x)
                     pos += count
 
-    return p
\ No newline at end of file
+    return p



More information about the Pypy-commit mailing list