Vladimir Marangozov: This fixes the line number in the string
authorGuido van Rossum <guido@python.org>
Fri, 7 Apr 2000 01:21:36 +0000 (01:21 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 7 Apr 2000 01:21:36 +0000 (01:21 +0000)
representation of code objects when optimization is on (python -O). It
was always reported as -1 instead of the real lineno.

Python/compile.c

index 5aaf15e15f4d1750573a426dcecfd0a1ebf0a3e2..d676b56929429abb9ce380b2e84603b1b874aa33 100644 (file)
@@ -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))