[pypy-svn] r45680 - in pypy/branch/pypy-more-rtti-inprogress: module/posix rpython/module translator/c/test

arigo at codespeak.net arigo at codespeak.net
Wed Aug 15 15:35:52 CEST 2007


Author: arigo
Date: Wed Aug 15 15:35:51 2007
New Revision: 45680

Modified:
   pypy/branch/pypy-more-rtti-inprogress/module/posix/interp_posix.py
   pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_environ.py
   pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py
Log:
Missed the KeyError on  del os.environ['unknown_name']


Modified: pypy/branch/pypy-more-rtti-inprogress/module/posix/interp_posix.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/module/posix/interp_posix.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/module/posix/interp_posix.py	Wed Aug 15 15:35:51 2007
@@ -264,7 +264,9 @@
 def unsetenv(space, name):
     """Delete an environment variable."""
     try:
-        os.unsetenv(name)
+        del os.environ[name]
+    except KeyError:
+        pass
     except OSError, e:
         raise wrap_oserror(space, e) 
 unsetenv.unwrap_spec = [ObjSpace, str]

Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_environ.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_environ.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_environ.py	Wed Aug 15 15:35:51 2007
@@ -27,6 +27,8 @@
 
     def delitem(self, obj, key):
         # in the RPython program, 'del os.environ[key]' is redirected here
+        if r_getenv(key) is None:
+            raise KeyError
         r_unsetenv(key)
 
     def get_keys(self, obj):

Modified: pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py	Wed Aug 15 15:35:51 2007
@@ -678,6 +678,12 @@
             del os.environ[s1]
             del os.environ[s2]
             del os.environ[s4]
+            try:
+                del os.environ[s2]
+            except KeyError:
+                pass
+            else:
+                raise Exception("should have raised!")
             # os.environ[s5] stays
     func = compile(fn, [str, str, str, str, str])
     if hasattr(__import__(os.name), 'unsetenv'):



More information about the Pypy-commit mailing list