[issue20149] 'with instance' references class's __enter__ attribute rather than instance's

2014-01-06 Thread Daniel Grace
New submission from Daniel Grace: I was writing code for a class that uses one threading.RLock per object. For convenience, I wanted to be able to use that lock's context manager and acquire/release methods without referencing the lock directly, so I opted to take a shortcut by assigning

[issue20149] 'with instance' references class's __enter__ attribute rather than instance's

2014-01-06 Thread R. David Murray
R. David Murray added the comment: magic methods like __enter__ and __exit__ are only looked up on the class, not on the instance. This is by design. In some older versions of Python some specific methods (and I think __enter__ and __exit__ were among them for a time) were looked up on the