Commit a396a883 authored by Guido van Rossum's avatar Guido van Rossum

Vladimir Marangozov: This fixes the line number in the string

representation of code objects when optimization is on (python -O). It
was always reported as -1 instead of the real lineno.
parent fa9ef186
...@@ -121,13 +121,11 @@ code_repr(co) ...@@ -121,13 +121,11 @@ code_repr(co)
{ {
char buf[500]; char buf[500];
int lineno = -1; int lineno = -1;
unsigned char *p;
char *filename = "???"; char *filename = "???";
char *name = "???"; char *name = "???";
_PyCode_GETCODEPTR(co, &p); if (co->co_firstlineno != 0)
if (*p == SET_LINENO) lineno = co->co_firstlineno;
lineno = (p[1] & 0xff) | ((p[2] & 0xff) << 8);
if (co->co_filename && PyString_Check(co->co_filename)) if (co->co_filename && PyString_Check(co->co_filename))
filename = PyString_AsString(co->co_filename); filename = PyString_AsString(co->co_filename);
if (co->co_name && PyString_Check(co->co_name)) if (co->co_name && PyString_Check(co->co_name))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment