From c86e93c05810de93ed12a1807b4d6a8ef10dbdfb Mon Sep 17 00:00:00 2001 From: "Michael W. Hudson" Date: Fri, 18 Jun 2004 11:41:03 +0000 Subject: [PATCH] Clarify why we don't do hasattr(var, '__exit__). --- pep-0310.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pep-0310.txt b/pep-0310.txt index 86a42f348..7b2cdf526 100644 --- a/pep-0310.txt +++ b/pep-0310.txt @@ -68,8 +68,9 @@ Basic Syntax and Semantics finally: var.__exit__() - Note that this makes using an object that does not have an - __exit__() method a fail-fast error. + (The presence of an __exit__ method is *not* checked like that of + __enter__ to ensure that using inappropriate objects in with: + statements gives an error). If the variable is omitted, an unnamed object is allocated on the stack. In that case, the suite has no access to the unnamed object.