__getattr__ doesn't work with __enter__ -> AttributeError
<p>I would like to use <code>with</code> on an object that uses <code>__getattr__</code> to redirect calls.<br>
Howerver, this does not seem to work with the method <code>__enter__</code></p>

<p>Please consider the following, simplified code to reproduce the error:</p>

<pre><code>class EnterTest(object):
    def myenter(self):
        pass
    def __exit__(self, type, value, traceback):
        pass

    def __getattr__(self, name):
        if name == '__enter__':
            return self.myenter

enter_obj = EnterTest()
print getattr(enter_obj, '__enter__')

with enter_obj:
    pass
</code></pre>

<p>Output:</p>

<pre><code>&lt;bound method EnterTest.myenter of &lt;__main__.EnterTest object at 0x00000000021432E8&gt;&gt;
Traceback (most recent call last):
  File "test.py", line 14, in &lt;module&gt;
    with enter_obj:
AttributeError: __enter__
</code></pre>

<p>Why doesn't it fall back to <code>__getattr__</code> since <code>__enter__</code> does not exist on the object?</p>

<p>Of course, I could make it work if I just create an <code>__enter__</code> method and redirect from there instead, but I'm wondering why it doesn't work otherwise.</p>

<p>My python version is the following:</p>

<pre><code>C:\Python27\python27.exe 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)]
</code></pre>
