]> granicus.if.org Git - python/commitdiff
When a foreign function is retrived by calling __getitem__ on a ctypes
authorThomas Heller <theller@ctypes.org>
Tue, 11 Jul 2006 18:28:35 +0000 (18:28 +0000)
committerThomas Heller <theller@ctypes.org>
Tue, 11 Jul 2006 18:28:35 +0000 (18:28 +0000)
library instance, do not set it as attribute.

Lib/ctypes/__init__.py

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