diff --git a/lib/utils/wrapper.py b/lib/utils/wrapper.py index 55cfbf21459ecdb3131cb5ce83f9f744e254f7fa..bedc1da55caabd55127fd548c941ee27119d618b 100644 --- a/lib/utils/wrapper.py +++ b/lib/utils/wrapper.py @@ -1,7 +1,7 @@ # # -# Copyright (C) 2006, 2007, 2010, 2011 Google Inc. +# Copyright (C) 2006, 2007, 2010, 2011, 2012 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ """ +import sys import time import socket import errno @@ -182,6 +183,11 @@ def ResetTempfileModule(_time=time.time): """ # pylint: disable=W0212 + if ((sys.hexversion >= 0x020703F0 and sys.hexversion < 0x03000000) or + sys.hexversion >=0x030203F0): + # Python 2.7 automatically resets the RNG on pid changes (i.e. forking) + return + try: lock = tempfile._once_lock lock.acquire() diff --git a/test/tempfile_fork_unittest.py b/test/tempfile_fork_unittest.py index 396c393a70b1ed048764cd7d6b27cbe57487c70a..b794e33e07ab8a6a60c6c0032027a6d71ff124cd 100755 --- a/test/tempfile_fork_unittest.py +++ b/test/tempfile_fork_unittest.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -# Copyright (C) 2010 Google Inc. +# Copyright (C) 2010, 2012 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -47,6 +47,14 @@ class TestResetTempfileModule(unittest.TestCase): shutil.rmtree(self.tmpdir) def testNoReset(self): + if ((sys.hexversion >= 0x020703F0 and sys.hexversion < 0x03000000) or + sys.hexversion >=0x030203F0): + # We can't test the no_reset case on Python 2.7+ + return + # evil Debian sid... + if (hasattr(tempfile._RandomNameSequence, "rng") and + type(tempfile._RandomNameSequence.rng) == property): + return self._Test(False) def testReset(self):