Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You were on the right track. When parsing the code tree, it just runs through <code>PyEval_FrameEx</code> multiple times. In the end, it will call <code>format_exc_check_arg()</code> to format the error, which for me happens at line 2100 in the <code>ceval.c</code> of the Python version 3.3.2 source. <code>format_exc_check_arg()</code> deduces the offensive 'object' (<code>prnt</code>) and calls <code>PyErr_Format</code> in <code>errors.c</code> to properly format the exception string (the exception type and its corresponding string, <code>NAME_ERROR_MSG</code>, were already passed to <code>format_exc_check_arg()</code> from this line 2100.</p> <p>I used simply this code for testing:</p> <pre><code>prnt('Line1') </code></pre> <p>and then run it through a <a href="http://docs.python.org/devguide/setup.html#compiling-for-debugging" rel="nofollow">debug build</a> of Python 3.3 I had around.</p> <p>The surrounding code in <code>PyEval_FrameEx</code> is</p> <pre><code> TARGET(LOAD_NAME) w = GETITEM(names, oparg); if ((v = f-&gt;f_locals) == NULL) { PyErr_Format(PyExc_SystemError, "no locals when loading %R", w); why = WHY_EXCEPTION; break; } if (PyDict_CheckExact(v)) { x = PyDict_GetItem(v, w); Py_XINCREF(x); } else { x = PyObject_GetItem(v, w); if (x == NULL &amp;&amp; PyErr_Occurred()) { if (!PyErr_ExceptionMatches( PyExc_KeyError)) break; PyErr_Clear(); } } if (x == NULL) { x = PyDict_GetItem(f-&gt;f_globals, w); Py_XINCREF(x); if (x == NULL) { if (PyDict_CheckExact(f-&gt;f_builtins)) { x = PyDict_GetItem(f-&gt;f_builtins, w); if (x == NULL) { // below is the line where the PyExc_NameError will be properly formatted. format_exc_check_arg( PyExc_NameError, NAME_ERROR_MSG, w); break; } Py_INCREF(x); } else { x = PyObject_GetItem(f-&gt;f_builtins, w); if (x == NULL) { if (PyErr_ExceptionMatches(PyExc_KeyError)) format_exc_check_arg( PyExc_NameError, NAME_ERROR_MSG, w); break; } } } } PUSH(x); DISPATCH(); </code></pre> <p>Note that two lines above it, <code>PyDict_GetItem(...)</code> will be the line trying to find <code>prnt</code> inside the builtin statements &amp; functions (I deduce that from <code>f-&gt;builtins</code>, to which <code>w</code> is applied, <code>w</code> itself gotten from the second statement in the above code. Since that dictionary lookup will fail, <code>x == NULL</code> and the <code>NameError</code> is set and formatted.</p> <p>Hope this helps you further.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload