[Python-checkins] CVS: python/dist/src/Lib/encodings __init__.py,1.7,1.8 aliases.py,1.12,1.13

M.-A. Lemburg lemburg@users.sourceforge.net
Mon, 11 Feb 2002 09:43:49 -0800


Update of /cvsroot/python/python/dist/src/Lib/encodings
In directory usw-pr-cvs1:/tmp/cvs-serv349/Lib/encodings

Modified Files:
	__init__.py aliases.py 
Log Message:
Corrected import behaviour for codecs which live outside the encodings
package.



Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/encodings/__init__.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** __init__.py	10 Feb 2002 21:36:20 -0000	1.7
--- __init__.py	11 Feb 2002 17:43:46 -0000	1.8
***************
*** 5,10 ****
  
      Codec modules must have names corresponding to standard lower-case
!     encoding names with hyphens and periods mapped to underscores,
!     e.g. 'utf-8' is implemented by the module 'utf_8.py'.
  
      Each codec module must export the following interface:
--- 5,10 ----
  
      Codec modules must have names corresponding to standard lower-case
!     encoding names with hyphens mapped to underscores, e.g. 'utf-8' is
!     implemented by the module 'utf_8.py'.
  
      Each codec module must export the following interface:
***************
*** 53,57 ****
      #
      modname = encoding.replace('-', '_')
-     modname = modname.replace('.', '_')
      try:
          mod = __import__('encodings.' + modname,
--- 53,56 ----
***************
*** 59,73 ****
      except ImportError,why:
          import aliases
!         modname = aliases.aliases.get(modname, _unknown)
!         if modname is not _unknown:
!             try:
!                 mod = __import__(modname,
!                                  globals(), locals(), _import_tail)
!             except ImportError,why:
!                 mod = None
!         else:
              mod = None
      if mod is None:
!         # cache misses
          _cache[encoding] = None
          return None
--- 58,68 ----
      except ImportError,why:
          import aliases
!         modname = aliases.aliases.get(modname, modname)
!         try:
!             mod = __import__(modname, globals(), locals(), _import_tail)
!         except ImportError,why:
              mod = None
      if mod is None:
!         # Cache misses
          _cache[encoding] = None
          return None

Index: aliases.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/encodings/aliases.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** aliases.py	10 Feb 2002 21:36:20 -0000	1.12
--- aliases.py	11 Feb 2002 17:43:46 -0000	1.13
***************
*** 5,10 ****
  
      Note that the search function converts the encoding names to lower
!     case and replaces hyphens and periods with underscores *before*
!     performing the lookup.
  
      Contents:
--- 5,10 ----
  
      Note that the search function converts the encoding names to lower
!     case and replaces hyphens with underscores *before* performing the
!     lookup.
  
      Contents:
***************
*** 26,36 ****
      # ascii codec
      '646'                : 'ascii',
!     'ansi_x3_4_1968'     : 'ascii',
!     'ansi_x3_4_1986'     : 'ascii',
      'cp367'              : 'ascii',
      'csascii'            : 'ascii',
      'ibm367'             : 'ascii',
      'iso646_us'          : 'ascii',
!     'iso_646_irv:1991'   : 'ascii',
      'iso_ir_6'           : 'ascii',
      'us'                 : 'ascii',
--- 26,36 ----
      # ascii codec
      '646'                : 'ascii',
!     'ansi_x3.4_1968'     : 'ascii',
!     'ansi_x3.4_1986'     : 'ascii',
      'cp367'              : 'ascii',
      'csascii'            : 'ascii',
      'ibm367'             : 'ascii',
      'iso646_us'          : 'ascii',
!     'iso_646.irv:1991'   : 'ascii',
      'iso_ir_6'           : 'ascii',
      'us'                 : 'ascii',