When a foreign function is retrived by calling __getitem__ on a ctypes

library instance, do not set it as attribute.
This commit is contained in:
Thomas Heller 2006-07-11 18:28:35 +00:00
parent b0aa54ece8
commit a42a662fec
1 changed files with 3 additions and 2 deletions

View File

@ -300,13 +300,14 @@ class CDLL(object):
def __getattr__(self, name): def __getattr__(self, name):
if name.startswith('__') and name.endswith('__'): if name.startswith('__') and name.endswith('__'):
raise AttributeError, name raise AttributeError, name
return self.__getitem__(name) func = self.__getitem__(name)
setattr(self, name, func)
return func
def __getitem__(self, name_or_ordinal): def __getitem__(self, name_or_ordinal):
func = self._FuncPtr((name_or_ordinal, self)) func = self._FuncPtr((name_or_ordinal, self))
if not isinstance(name_or_ordinal, (int, long)): if not isinstance(name_or_ordinal, (int, long)):
func.__name__ = name_or_ordinal func.__name__ = name_or_ordinal
setattr(self, name_or_ordinal, func)
return func return func
class PyDLL(CDLL): class PyDLL(CDLL):