puzzled about old checkin to pythonrun.c

Fred, You made a change to the syntax error generation code last August. I don't understand what the code is doing. It appears that the code you added is redundant, but it's hard to tell for sure because responsbility for generating well-formed SyntaxErrors is spread across several files. The code you added in pythonrun.c, line 1084, in err_input(), starts with the test (v != NULL): w = Py_BuildValue("(sO)", msg, v); PyErr_SetObject(errtype, w); Py_XDECREF(w); if (v != NULL) { PyObject *exc, *tb; PyErr_Fetch(&errtype, &exc, &tb); PyErr_NormalizeException(&errtype, &exc, &tb); if (PyObject_SetAttrString(exc, "filename", PyTuple_GET_ITEM(v, 0))) PyErr_Clear(); if (PyObject_SetAttrString(exc, "lineno", PyTuple_GET_ITEM(v, 1))) PyErr_Clear(); if (PyObject_SetAttrString(exc, "offset", PyTuple_GET_ITEM(v, 2))) PyErr_Clear(); Py_DECREF(v); PyErr_Restore(errtype, exc, tb); } What's weird about this code is that the __init__ code for a SyntaxError (all errors will be SyntaxErrors at this point) sets filename, lineno, and offset. Each of the values is passed to the constructor as the tuple v; then the new code gets the items out of the tuple and sets the explicitly. You also made a bunch of changes to SyntaxError__str__ at the same time. I wonder if they were sufficient to fix the bug (which has tracker aid 210628 incidentally). Can you shed any light? Jeremy

Jeremy Hylton writes:
This is probably the biggest reason it's taken so long to get things into the ballpark!
The code you added in pythonrun.c, line 1084, in err_input(), starts with the test (v != NULL):
I've ripped all that out.
Can you shed any light?
Was this all the light you needed? Or was there something deeper that I'm missing? -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations

Jeremy Hylton writes:
This is probably the biggest reason it's taken so long to get things into the ballpark!
The code you added in pythonrun.c, line 1084, in err_input(), starts with the test (v != NULL):
I've ripped all that out.
Can you shed any light?
Was this all the light you needed? Or was there something deeper that I'm missing? -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations
participants (3)
-
Fred L. Drake, Jr.
-
Fred L. Drake, Jr.
-
Jeremy Hylton