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
3eed7652
Commit
3eed7652
authored
Aug 14, 2007
by
Collin Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #1772489: make dir() work on traceback objects again.
parent
ee634a40
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+7
-0
Python/traceback.c
Python/traceback.c
+13
-1
No files found.
Lib/test/test_builtin.py
View file @
3eed7652
...
...
@@ -283,6 +283,13 @@ class BuiltinTest(unittest.TestCase):
f
=
Foo
()
self
.
assertRaises
(
TypeError
,
dir
,
f
)
# dir(traceback)
try
:
raise
IndexError
except
:
self
.
assertEqual
(
len
(
dir
(
sys
.
exc_info
()[
2
])),
4
)
def
test_divmod
(
self
):
self
.
assertEqual
(
divmod
(
12
,
7
),
(
1
,
5
))
self
.
assertEqual
(
divmod
(
-
12
,
7
),
(
-
2
,
2
))
...
...
Python/traceback.c
View file @
3eed7652
...
...
@@ -11,6 +11,18 @@
#define OFF(x) offsetof(PyTracebackObject, x)
static
PyObject
*
tb_dir
(
PyTracebackObject
*
self
)
{
return
Py_BuildValue
(
"[ssss]"
,
"tb_frame"
,
"tb_next"
,
"tb_lasti"
,
"tb_lineno"
);
}
static
PyMethodDef
tb_methods
[]
=
{
{
"__dir__"
,
(
PyCFunction
)
tb_dir
,
METH_NOARGS
},
{
NULL
,
NULL
,
0
,
NULL
},
};
static
PyMemberDef
tb_memberlist
[]
=
{
{
"tb_next"
,
T_OBJECT
,
OFF
(
tb_next
),
READONLY
},
{
"tb_frame"
,
T_OBJECT
,
OFF
(
tb_frame
),
READONLY
},
...
...
@@ -73,7 +85,7 @@ PyTypeObject PyTraceBack_Type = {
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
0
,
/* tp_methods */
tb_methods
,
/* tp_methods */
tb_memberlist
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
...
...
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