A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-February/013275.html below:

[Python-Dev] puzzled about old checkin to pythonrun.c

[Python-Dev] puzzled about old checkin to pythonrun.cJeremy Hylton jeremy@alum.mit.edu
Wed, 28 Feb 2001 00:28:08 -0500 (EST)
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





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4