summaryrefslogtreecommitdiff
blob: 83bfc0e6bceba9221989f202ab3f0f8cd30f4aaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
? classObject__name__.patch
Index: pychecker/checker.py
===================================================================
--- pychecker/checker.py.orig
+++ pychecker/checker.py
@@ -248,6 +248,17 @@ class Class :
             if mo:
                 modname = ".".join(mo.group(1).split(".")[:-1])
 
+        # zope.interface for example has Provides and Declaration that
+        # look a lot like class objects but do not have __name__
+        if hasattr(self.classObject, '__name__'):
+            self.classObject__name__ = self.classObject.__name__
+        else:
+            if modname not in cfg().blacklist:
+                sys.stderr.write("warning: no __name__ attribute "
+                                 "for class %s (module name: %s)\n"
+                                 % (self.classObject, modname))
+            self.classObject__name__ = name
+
         self.module = sys.modules.get(modname)
         if not self.module:
             self.module = module
@@ -329,7 +340,7 @@ class Class :
         self.cleanupMemberRefs()
         # add standard methods
         for methodName in ('__class__',) :
-            self.addMethod(methodName, classObject.__name__)
+            self.addMethod(methodName, self.classObject__name__)
 
     def addMembers(self, classObject) :
         if not cfg().onlyCheckInitForMembers :