mirror of https://github.com/python/cpython.git
fix strange errors when setting attributes on tracebacks #4034
This commit is contained in:
parent
7c33bd5ecb
commit
6ffe852f90
|
@ -111,14 +111,6 @@ def test():
|
||||||
os.unlink(os.path.join(testdir, f))
|
os.unlink(os.path.join(testdir, f))
|
||||||
os.rmdir(testdir)
|
os.rmdir(testdir)
|
||||||
|
|
||||||
def test_members(self):
|
|
||||||
# Covers Python/structmember.c::listmembers()
|
|
||||||
try:
|
|
||||||
1/0
|
|
||||||
except:
|
|
||||||
import sys
|
|
||||||
sys.exc_traceback.__members__
|
|
||||||
|
|
||||||
def test_base_exception(self):
|
def test_base_exception(self):
|
||||||
# Test that exceptions derived from BaseException are formatted right
|
# Test that exceptions derived from BaseException are formatted right
|
||||||
e = KeyboardInterrupt()
|
e = KeyboardInterrupt()
|
||||||
|
|
|
@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #4034: Fix weird attribute error messages of the traceback object. (As a
|
||||||
|
result traceback.__members__ no longer exists.)
|
||||||
|
|
||||||
- Issue #4474: PyUnicode_FromWideChar now converts characters outside
|
- Issue #4474: PyUnicode_FromWideChar now converts characters outside
|
||||||
the BMP to surrogate pairs, on systems with sizeof(wchar_t) == 4
|
the BMP to surrogate pairs, on systems with sizeof(wchar_t) == 4
|
||||||
and sizeof(Py_UNICODE) == 2.
|
and sizeof(Py_UNICODE) == 2.
|
||||||
|
|
|
@ -604,7 +604,17 @@ static PyObject *builtin_object;
|
||||||
int _PyFrame_Init()
|
int _PyFrame_Init()
|
||||||
{
|
{
|
||||||
builtin_object = PyString_InternFromString("__builtins__");
|
builtin_object = PyString_InternFromString("__builtins__");
|
||||||
return (builtin_object != NULL);
|
if (builtin_object == NULL)
|
||||||
|
return 0;
|
||||||
|
/*
|
||||||
|
Traceback objects are not created the normal way (through calling the
|
||||||
|
type), so PyType_Ready has to be called here.
|
||||||
|
*/
|
||||||
|
if (PyType_Ready(&PyTraceBack_Type)) {
|
||||||
|
Py_DECREF(builtin_object);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyFrameObject *
|
PyFrameObject *
|
||||||
|
|
|
@ -11,20 +11,14 @@
|
||||||
|
|
||||||
#define OFF(x) offsetof(PyTracebackObject, x)
|
#define OFF(x) offsetof(PyTracebackObject, x)
|
||||||
|
|
||||||
static struct memberlist tb_memberlist[] = {
|
static PyMemberDef tb_memberlist[] = {
|
||||||
{"tb_next", T_OBJECT, OFF(tb_next)},
|
{"tb_next", T_OBJECT, OFF(tb_next), READONLY},
|
||||||
{"tb_frame", T_OBJECT, OFF(tb_frame)},
|
{"tb_frame", T_OBJECT, OFF(tb_frame), READONLY},
|
||||||
{"tb_lasti", T_INT, OFF(tb_lasti)},
|
{"tb_lasti", T_INT, OFF(tb_lasti), READONLY},
|
||||||
{"tb_lineno", T_INT, OFF(tb_lineno)},
|
{"tb_lineno", T_INT, OFF(tb_lineno), READONLY},
|
||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject *
|
|
||||||
tb_getattr(PyTracebackObject *tb, char *name)
|
|
||||||
{
|
|
||||||
return PyMember_Get((char *)tb, tb_memberlist, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tb_dealloc(PyTracebackObject *tb)
|
tb_dealloc(PyTracebackObject *tb)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +52,7 @@ PyTypeObject PyTraceBack_Type = {
|
||||||
0,
|
0,
|
||||||
(destructor)tb_dealloc, /*tp_dealloc*/
|
(destructor)tb_dealloc, /*tp_dealloc*/
|
||||||
0, /*tp_print*/
|
0, /*tp_print*/
|
||||||
(getattrfunc)tb_getattr, /*tp_getattr*/
|
0, /*tp_getattr*/
|
||||||
0, /*tp_setattr*/
|
0, /*tp_setattr*/
|
||||||
0, /*tp_compare*/
|
0, /*tp_compare*/
|
||||||
0, /*tp_repr*/
|
0, /*tp_repr*/
|
||||||
|
@ -80,8 +74,8 @@ PyTypeObject PyTraceBack_Type = {
|
||||||
0, /* tp_iter */
|
0, /* tp_iter */
|
||||||
0, /* tp_iternext */
|
0, /* tp_iternext */
|
||||||
0, /* tp_methods */
|
0, /* tp_methods */
|
||||||
0, /* tp_members */
|
tb_memberlist, /* tp_members */
|
||||||
0, /* tp_getset */
|
0, /* tp_getset */
|
||||||
0, /* tp_base */
|
0, /* tp_base */
|
||||||
0, /* tp_dict */
|
0, /* tp_dict */
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue