]> granicus.if.org Git - python/commit
Updates to the with-statement:
authorGuido van Rossum <guido@python.org>
Tue, 28 Feb 2006 21:57:43 +0000 (21:57 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 28 Feb 2006 21:57:43 +0000 (21:57 +0000)
commit1a5e21e0334a6d4e1c756575023c7157fc9ee306
treed2c1c9383b3c6d8194449ae756e663b0b0ac9e4e
parent87a8b4fee56b8204ee9f7b0ce2e5db0564e8f86e
Updates to the with-statement:

- New semantics for __exit__() -- it must re-raise the exception
  if type is not None; the with-statement itself doesn't do this.
  (See the updated PEP for motivation.)

- Added context managers to:
  - file
  - thread.LockType
  - threading.{Lock,RLock,Condition,Semaphore,BoundedSemaphore}
  - decimal.Context

- Added contextlib.py, which defines @contextmanager, nested(), closing().

- Unit tests all around; bot no docs yet.
12 files changed:
Lib/contextlib.py [new file with mode: 0644]
Lib/decimal.py
Lib/test/contextmanager.py [deleted file]
Lib/test/nested.py [deleted file]
Lib/test/test_contextlib.py [new file with mode: 0644]
Lib/test/test_with.py
Lib/threading.py
Misc/NEWS
Modules/threadmodule.c
Objects/fileobject.c
Python/ceval.c
Python/errors.c