[Python-checkins] python/dist/src/Lib/test test_xmlrpc.py, 1.5.4.1, 1.5.4.2

anthonybaxter@users.sourceforge.net anthonybaxter at users.sourceforge.net
Tue Sep 20 17:17:20 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13059

Modified Files:
      Tag: release24-maint
	test_xmlrpc.py 
Log Message:
backport: 
test_default_encoding_issues():  Fully restore sys.setdefaultencoding.

test_site often failed under "regrtest.py -r", because this xmlrpc test
left sys with a setdefaultencoding attribute, but loading site.py removes
that attribute and test_site.py verifies the attribute is gone.  Changed
this test to get rid of sys.setdefaultencoding if it didn't exist when
this test started.


Index: test_xmlrpc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_xmlrpc.py,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -u -d -r1.5.4.1 -r1.5.4.2
--- test_xmlrpc.py	11 Feb 2005 18:00:16 -0000	1.5.4.1
+++ test_xmlrpc.py	20 Sep 2005 15:17:16 -0000	1.5.4.2
@@ -63,13 +63,20 @@
                       </value></param>
                   </params>
                   """
+
+        # sys.setdefaultencoding() normally doesn't exist after site.py is
+        # loaded.  reload(sys) is the way to get it back.
         old_encoding = sys.getdefaultencoding()
+        setdefaultencoding_existed = hasattr(sys, "setdefaultencoding")
         reload(sys) # ugh!
         sys.setdefaultencoding("iso-8859-1")
         try:
             (s, d), m = xmlrpclib.loads(utf8)
         finally:
             sys.setdefaultencoding(old_encoding)
+            if not setdefaultencoding_existed:
+                del sys.setdefaultencoding
+
         items = d.items()
         if have_unicode:
             self.assertEquals(s, u"abc \x95")



More information about the Python-checkins mailing list