mirror of
https://github.com/python/cpython.git
synced 2024-11-28 20:33:54 +08:00
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.
This commit is contained in:
parent
fa9ef1864f
commit
a396a883af
@ -121,13 +121,11 @@ code_repr(co)
|
||||
{
|
||||
char buf[500];
|
||||
int lineno = -1;
|
||||
unsigned char *p;
|
||||
char *filename = "???";
|
||||
char *name = "???";
|
||||
|
||||
_PyCode_GETCODEPTR(co, &p);
|
||||
if (*p == SET_LINENO)
|
||||
lineno = (p[1] & 0xff) | ((p[2] & 0xff) << 8);
|
||||
if (co->co_firstlineno != 0)
|
||||
lineno = co->co_firstlineno;
|
||||
if (co->co_filename && PyString_Check(co->co_filename))
|
||||
filename = PyString_AsString(co->co_filename);
|
||||
if (co->co_name && PyString_Check(co->co_name))
|
||||
|
Loading…
Reference in New Issue
Block a user