[pypy-commit] pypy default: Clean up test_unicode_join_str_arg_utf8 a bit.

dripton noreply at buildbot.pypy.org
Mon Mar 12 23:36:01 CET 2012


Author: David Ripton <dripton at ripton.net>
Branch: 
Changeset: r53368:5e696214e57c
Date: 2012-03-12 15:27 -0700
http://bitbucket.org/pypy/pypy/changeset/5e696214e57c/

Log:	Clean up test_unicode_join_str_arg_utf8 a bit.

diff --git a/pypy/objspace/std/test/test_stringobject.py b/pypy/objspace/std/test/test_stringobject.py
--- a/pypy/objspace/std/test/test_stringobject.py
+++ b/pypy/objspace/std/test/test_stringobject.py
@@ -513,25 +513,21 @@
         # import.
         self.original_modules = sys.modules.copy()
         try:
-            for module_name in ['sys']:
-                if module_name in sys.modules:
-                    module = sys.modules[module_name]
-                    # It is possible that module_name is just an alias for
-                    # another module (e.g. stub for modules renamed in 3.x).
-                    # In that case, we also need delete the real module to
-                    # clear the import cache.
-                    if module.__name__ != module_name:
-                        del sys.modules[module.__name__]
-                    del sys.modules[module_name]
             import sys as temp_sys
+            module_name = 'sys'
+            if module_name in sys.modules:
+                module = sys.modules[module_name]
+                # It is possible that module_name is just an alias for
+                # another module (e.g. stub for modules renamed in 3.x).
+                # In that case, we also need delete the real module to
+                # clear the import cache.
+                if module.__name__ != module_name:
+                    del sys.modules[module.__name__]
+                del sys.modules[module_name]
             temp_sys.setdefaultencoding('utf-8')
             assert u''.join(['\xc3\xa1']) == u'\xe1'
         finally:
-            try:
-                temp_sys.setdefaultencoding(old_encoding)
-            except NameError:
-                # It failed before we declared temp_sys
-                pass
+            temp_sys.setdefaultencoding(old_encoding)
             sys.modules.update(self.original_modules)
 
     def test_unicode_join_endcase(self):


More information about the pypy-commit mailing list