summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2006-07-11 18:28:35 (GMT)
committerThomas Heller <theller@ctypes.org>2006-07-11 18:28:35 (GMT)
commita42a662fec39e5b34219bbd80bb472da1fe3eb38 (patch)
tree0582336aca27b2513d227c8af87b7e073be76df2
parentb0aa54ece8b70ea4e10c0f5e6e1d408dfe01a89f (diff)
downloadcpython-a42a662fec39e5b34219bbd80bb472da1fe3eb38.zip
cpython-a42a662fec39e5b34219bbd80bb472da1fe3eb38.tar.gz
cpython-a42a662fec39e5b34219bbd80bb472da1fe3eb38.tar.bz2
When a foreign function is retrived by calling __getitem__ on a ctypes
library instance, do not set it as attribute.
-rw-r--r--Lib/ctypes/__init__.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
index 083d0f1..5da1849 100644
--- a/Lib/ctypes/__init__.py
+++ b/Lib/ctypes/__init__.py
@@ -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):