Revision: 138
Author: psoberoi
Date: Fri May 7 09:04:34 2010
Log: prevent lokups of __special__ methods from invoking the automatic
config addition machinery, and remove the special hacks for __getattr__,
__reduce__, __reduce_ex__, and __getnewargs__.
http://code.google.com/p/iniparse/source/detail?r=138
Modified:
/trunk/iniparse/config.py
=======================================
--- /trunk/iniparse/config.py Thu May 6 22:50:17 2010
+++ /trunk/iniparse/config.py Fri May 7 09:04:34 2010
@@ -47,6 +47,8 @@
try:
return self.__getitem__(name)
except KeyError:
+ if name.startswith('__') and name.endswith('__'):
+ raise AttributeError
return Undefined(name, self)
def __setattr__(self, name, value):
@@ -63,18 +65,13 @@
except AttributeError:
self.__delitem__(name)
- def __getstate__(self):
- return self.__dict__
-
+ # During unpickling, __getattr__/__getitem__ raise exceptions since
+ # the data dicts have not been initialized yet. So, the attribute
+ # lookup for __setstate__ gets a non-AttributeError exception. Thus
+ # we need to define it explicitly.
def __setstate__(self, state):
self.__dict__.update(state)
- __reduce__ = object.__reduce__
- __reduce_ex__ = object.__reduce_ex__
-
- def __getnewargs__(self):
- return ()
-
class Undefined(object):
"""Helper class used to hold undefined names until assignment.
--
To post to this group, send email to
iniparse...@googlegroups.com
To unsubscribe from this group, send email to
iniparse-commi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/iniparse-commits?hl=en