RE: RE: Python 2.3 compatibility?
"Bauer, Georg" <[email protected]> Tue, 20 Jan 2004 15:30:27 +0100
| Newsgroups | gmane.comp.pythin.pyds.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi! > Are you implementing __getattr__? Because that behaves a lot > differently for classic and new-style classes. Yep, some classes (like NuggetTool and MacrosTool) implement __getattr__ to allow access to user defined elements from the database in the same way as programmer provided attributes. And it only uses classic classes. > >>> class Foo: > ... def __getattr__(self, foo): > ... print foo > ... > >>> f = Foo() > >>> f > __repr__ > Traceback (most recent call last): > File "<stdin>", line 1, in ? > TypeError: 'NoneType' object is not callable > > > >>> class F(object): > ... def __getattr__(self, foo): > ... print foo > ... > >>> > >>> f = F() > >>> f > <__main__.F object at 0x554d0> Hmm. But this is exactly the same way in Python 2.2 (just tried it) - but the problem Michel reported doesn't show up in Python 2.2 running PyDS, only in Python 2.3. But it might be that it did show up with 2.2 before, but nobody ever noticed (although I know that some people actively use the pyds-restore feature and NuggetsTool is rather old). I added a __nonzero__ definition that just returns 1 to all classes that make use of __getattr__ (that's the Context and NuggetsTool and MacrosTool), as that shouldn't do any harm. If anybody has the listed problems with weird __nonzero__ keyerrors or NoneType not calleable exceptions, please try the CVS version wether that solves your problems. bye, Georg