From: Brett Cannon Date: Sun, 13 Jul 2008 01:15:07 +0000 (+0000) Subject: dummy_thread.acquire() would return None if no waitflag argument was given. It X-Git-Tag: v2.6b2~62 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d0b9f095a1ccda7d6c04a9a1d05d245d8b82e26;p=python dummy_thread.acquire() would return None if no waitflag argument was given. It should have returned True. Fixes issue #3339. Thanks, Henk Punt for the report and Andrii v. Mishkovskiyi for attempting a patch. --- diff --git a/Lib/dummy_thread.py b/Lib/dummy_thread.py index c1313846e4..16dcf7e9a2 100644 --- a/Lib/dummy_thread.py +++ b/Lib/dummy_thread.py @@ -104,18 +104,15 @@ class LockType(object): aren't triggered and throw a little fit. """ - if waitflag is None: + if waitflag is None or waitflag: self.locked_status = True - return None - elif not waitflag: + return True + else: if not self.locked_status: self.locked_status = True return True else: return False - else: - self.locked_status = True - return True __enter__ = acquire diff --git a/Lib/test/test_dummy_thread.py b/Lib/test/test_dummy_thread.py index f274e0a0d0..58faeb4289 100644 --- a/Lib/test/test_dummy_thread.py +++ b/Lib/test/test_dummy_thread.py @@ -60,6 +60,7 @@ class LockTests(unittest.TestCase): #Make sure that an unconditional locking returns True. self.failUnless(self.lock.acquire(1) is True, "Unconditional locking did not return True.") + self.failUnless(self.lock.acquire() is True) def test_uncond_acquire_blocking(self): #Make sure that unconditional acquiring of a locked lock blocks. diff --git a/Misc/NEWS b/Misc/NEWS index f026a09bbf..ecd5567c0a 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,7 +10,6 @@ What's New in Python 2.6 beta 2? Core and Builtins ----------------- - - Issue #2517: Allow unicode messages in Exceptions again by correctly bypassing the instance dictionary when looking up __unicode__ on new-style classes. @@ -41,6 +40,8 @@ Core and Builtins Library ------- +- Issue #3339: dummy_thread.acquire() should not return None. + - Issue #3285: Fractions from_float() and from_decimal() accept Integral arguments. - Issue #3301: Bisect module behaved badly when lo was negative.