From: Benjamin Peterson Date: Sun, 31 May 2009 15:00:27 +0000 (+0000) Subject: __enter__ and __exit__ must be on the class X-Git-Tag: v2.7a1~1057 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb88cb8cd44c52c9619b2137d501b8195ecebd79;p=python __enter__ and __exit__ must be on the class --- diff --git a/Lib/multiprocessing/synchronize.py b/Lib/multiprocessing/synchronize.py index 716f3c7003..6f90cb575e 100644 --- a/Lib/multiprocessing/synchronize.py +++ b/Lib/multiprocessing/synchronize.py @@ -58,8 +58,12 @@ class SemLock(object): def _make_methods(self): self.acquire = self._semlock.acquire self.release = self._semlock.release - self.__enter__ = self._semlock.__enter__ - self.__exit__ = self._semlock.__exit__ + + def __enter__(self): + return self._semlock.__enter__() + + def __exit__(self, *args): + return self._semlock.__exit__(*args) def __getstate__(self): assert_spawning(self) @@ -181,11 +185,15 @@ class Condition(object): self._woken_count, self._wait_semaphore) = state self._make_methods() + def __enter__(self): + return self._lock.__enter__() + + def __exit__(self, *args): + return self._lock.__exit__(*args) + def _make_methods(self): self.acquire = self._lock.acquire self.release = self._lock.release - self.__enter__ = self._lock.__enter__ - self.__exit__ = self._lock.__exit__ def __repr__(self): try: