]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Use AttributeError
authorGuido van Rossum <guido@python.org>
Thu, 26 Dec 1991 13:04:02 +0000 (13:04 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 26 Dec 1991 13:04:02 +0000 (13:04 +0000)
Lib/lib-old/newdir.py
Lib/newdir.py

index 7164b989743c5ecca4f719509d1780eb3d52470b..9d07d6ceb28e1123f877b623d3a58629a8a3200f 100644 (file)
@@ -11,27 +11,27 @@ def getattr(x, name):
 def listattrs(x):
        try:
                dictkeys = x.__dict__.keys()
-       except (NameError, TypeError):
+       except (AttributeError, TypeError):
                dictkeys = []
        #
        try:
                methods = x.__methods__
-       except (NameError, TypeError):
+       except (AttributeError, TypeError):
                methods = []
        #
        try:
                members = x.__members__
-       except (NameError, TypeError):
+       except (AttributeError, TypeError):
                members = []
        #
        try:
                the_class = x.__class__
-       except (NameError, TypeError):
+       except (AttributeError, TypeError):
                the_class = None
        #
        try:
                bases = x.__bases__
-       except (NameError, TypeError):
+       except (AttributeError, TypeError):
                bases = ()
        #
        total = dictkeys + methods + members
@@ -69,7 +69,7 @@ def is_function(x):
 # Use a class method to make a function that can be called
 # with or without arguments.
 #
-class _dirclass():
+class _dirclass:
        def dir(args):
                if type(args) = type(()):
                        return listattrs(args[1])
index 7164b989743c5ecca4f719509d1780eb3d52470b..9d07d6ceb28e1123f877b623d3a58629a8a3200f 100644 (file)
@@ -11,27 +11,27 @@ def getattr(x, name):
 def listattrs(x):
        try:
                dictkeys = x.__dict__.keys()
-       except (NameError, TypeError):
+       except (AttributeError, TypeError):
                dictkeys = []
        #
        try:
                methods = x.__methods__
-       except (NameError, TypeError):
+       except (AttributeError, TypeError):
                methods = []
        #
        try:
                members = x.__members__
-       except (NameError, TypeError):
+       except (AttributeError, TypeError):
                members = []
        #
        try:
                the_class = x.__class__
-       except (NameError, TypeError):
+       except (AttributeError, TypeError):
                the_class = None
        #
        try:
                bases = x.__bases__
-       except (NameError, TypeError):
+       except (AttributeError, TypeError):
                bases = ()
        #
        total = dictkeys + methods + members
@@ -69,7 +69,7 @@ def is_function(x):
 # Use a class method to make a function that can be called
 # with or without arguments.
 #
-class _dirclass():
+class _dirclass:
        def dir(args):
                if type(args) = type(()):
                        return listattrs(args[1])