[pypy-commit] pypy default: Win32: pass test_rposix.test_putenv

arigo pypy.commits at gmail.com
Tue Nov 8 13:11:01 EST 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r88224:aa00ccf8fdaf
Date: 2016-11-08 19:09 +0100
http://bitbucket.org/pypy/pypy/changeset/aa00ccf8fdaf/

Log:	Win32: pass test_rposix.test_putenv

diff --git a/rpython/rlib/rposix_environ.py b/rpython/rlib/rposix_environ.py
--- a/rpython/rlib/rposix_environ.py
+++ b/rpython/rlib/rposix_environ.py
@@ -201,6 +201,8 @@
     # default implementation for platforms without a real unsetenv()
     r_putenv(name, '')
 
+REAL_UNSETENV = False
+
 if hasattr(__import__(os.name), 'unsetenv'):
     os_unsetenv = rffi.llexternal('unsetenv', [rffi.CCHARP], rffi.INT,
                                   save_err=rffi.RFFI_SAVE_ERRNO)
@@ -222,3 +224,4 @@
     register_external(r_unsetenv, [str0], annmodel.s_None,
                       export_name='ll_os.ll_os_unsetenv',
                       llimpl=unsetenv_llimpl)
+    REAL_UNSETENV = True
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -470,11 +470,18 @@
         assert rposix.is_valid_fd(fd) == 0
 
     def test_putenv(self):
+        from rpython.rlib import rposix_environ
+
         def f():
             rposix.putenv(self.path, self.path)
             rposix.unsetenv(self.path)
 
-        interpret(f, []) # does not crash
+        interpret(f, [],     # does not crash
+                  malloc_check=rposix_environ.REAL_UNSETENV)
+        # If we have a real unsetenv(), check that it frees the string
+        # kept alive by putenv().  Otherwise, we can't check that,
+        # because unsetenv() will keep another string alive itself.
+    test_putenv.dont_track_allocations = True
 
 
 class TestPosixAscii(BasePosixUnicodeOrAscii):


More information about the pypy-commit mailing list