Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
946749f6
Commit
946749f6
authored
Dec 26, 1991
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use AttributeError
parent
2234bc91
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
Lib/lib-old/newdir.py
Lib/lib-old/newdir.py
+6
-6
Lib/newdir.py
Lib/newdir.py
+6
-6
No files found.
Lib/lib-old/newdir.py
View file @
946749f6
...
...
@@ -11,27 +11,27 @@ def getattr(x, name):
def
listattrs
(
x
):
try
:
dictkeys
=
x
.
__dict__
.
keys
()
except
(
Nam
eError
,
TypeError
):
except
(
Attribut
eError
,
TypeError
):
dictkeys
=
[]
#
try
:
methods
=
x
.
__methods__
except
(
Nam
eError
,
TypeError
):
except
(
Attribut
eError
,
TypeError
):
methods
=
[]
#
try
:
members
=
x
.
__members__
except
(
Nam
eError
,
TypeError
):
except
(
Attribut
eError
,
TypeError
):
members
=
[]
#
try
:
the_class
=
x
.
__class__
except
(
Nam
eError
,
TypeError
):
except
(
Attribut
eError
,
TypeError
):
the_class
=
None
#
try
:
bases
=
x
.
__bases__
except
(
Nam
eError
,
TypeError
):
except
(
Attribut
eError
,
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
])
...
...
Lib/newdir.py
View file @
946749f6
...
...
@@ -11,27 +11,27 @@ def getattr(x, name):
def
listattrs
(
x
):
try
:
dictkeys
=
x
.
__dict__
.
keys
()
except
(
Nam
eError
,
TypeError
):
except
(
Attribut
eError
,
TypeError
):
dictkeys
=
[]
#
try
:
methods
=
x
.
__methods__
except
(
Nam
eError
,
TypeError
):
except
(
Attribut
eError
,
TypeError
):
methods
=
[]
#
try
:
members
=
x
.
__members__
except
(
Nam
eError
,
TypeError
):
except
(
Attribut
eError
,
TypeError
):
members
=
[]
#
try
:
the_class
=
x
.
__class__
except
(
Nam
eError
,
TypeError
):
except
(
Attribut
eError
,
TypeError
):
the_class
=
None
#
try
:
bases
=
x
.
__bases__
except
(
Nam
eError
,
TypeError
):
except
(
Attribut
eError
,
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
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment