[Python-checkins] python/dist/src/Lib/email Charset.py,1.2,1.3

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Tue, 28 May 2002 11:49:06 -0700


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

Modified Files:
	Charset.py 
Log Message:
Importing Charset should not fail when Unicode is disabled.  (XXX
Using Unicode-aware methods may still die with a NameError on unicode.
Maybe there's a more elegant solution but I doubt anybody cares.)


Index: Charset.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Charset.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Charset.py	23 May 2002 15:15:29 -0000	1.2
--- Charset.py	28 May 2002 18:49:03 -0000	1.3
***************
*** 2,6 ****
  # Author: che@debian.org (Ben Gertzfield)
  
! from types import UnicodeType
  from email.Encoders import encode_7or8bit
  import email.base64MIME
--- 2,14 ----
  # Author: che@debian.org (Ben Gertzfield)
  
! try:
!     unicode
! except NameError:
!     def _is_unicode(x):
!         return 1==0
! else:
!     def _is_unicode(x):
!         return isinstance(x, unicode)
!     
  from email.Encoders import encode_7or8bit
  import email.base64MIME
***************
*** 227,231 ****
          with the Unicode replacement character U+FFFD.
          """
!         if isinstance(s, UnicodeType) or self.input_codec is None:
              return s
          try:
--- 235,239 ----
          with the Unicode replacement character U+FFFD.
          """
!         if _is_unicode(s) or self.input_codec is None:
              return s
          try:
***************
*** 255,259 ****
          else:
              codec = self.input_codec
!         if not isinstance(ustr, UnicodeType) or codec is None:
              return ustr
          try:
--- 263,267 ----
          else:
              codec = self.input_codec
!         if not _is_unicode(ustr) or codec is None:
              return ustr
          try: