Use py3k compatible .__getattr__() code

From the python-dev thread it seemed like using
object.__getattribute__(self, 'name') is the cleanest way of
implementing a class wich uses .__getattr__() and should be
pickelable.  That only works on new-style classes so this also turns
HookProxy into a new-style class on py2.

This also re-writes the test to not use cPickle so it runs on py3k.
This commit is contained in:
Floris Bruynooghe
2014-09-05 23:55:14 +01:00
parent d1bde69c1e
commit 7d9d502a01
4 changed files with 11 additions and 15 deletions
+1 -4
View File
@@ -238,10 +238,7 @@ class EncodedFile(object):
self.write(data)
def __getattr__(self, name):
if hasattr(self, "buffer"):
return getattr(self.buffer, name)
else:
raise AttributeError("attribute buffer of %r not set" % self)
return getattr(object.__getattribute__(self, "buffer"), name)
class MultiCapture(object):