Commit Graph

5 Commits

Author SHA1 Message Date
Phillip J. Eby ccc7bb4ef2 More extensive comment on __exit__ handling, per Guido's request. 2006-03-25 04:32:12 +00:00
Phillip J. Eby 6edd258608 Fix a problem with @contextmanager not detecting a broken generator
that yields after a throw().  Make @contextmanager not reraise
exceptions, but return a false value in that case instead.  Add test
cases for both behaviors.
2006-03-25 00:28:24 +00:00
Guido van Rossum f669436189 Um, I thought I'd already checked this in.
Anyway, this is the changes to the with-statement
so that __exit__ must return a true value in order
for a pending exception to be ignored.
The PEP (343) is already updated.
2006-03-10 02:28:35 +00:00
Guido van Rossum a9f068726f Fix a bug in nested() - if one of the sub-context-managers swallows the
exception, it should not be propagated up.  With unit tests.
2006-03-01 17:10:01 +00:00
Guido van Rossum 1a5e21e033 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.
2006-02-28 21:57:43 +00:00