[Patches] code_repr lineno fix for -O

Vladimir Marangozov Vladimir.Marangozov@inrialpes.fr
Fri, 7 Apr 2000 02:16:31 +0200 (CEST)


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.

-- 
       Vladimir MARANGOZOV          | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252

--
I confirm that, to the best of my knowledge and belief, this contribution is
free of any claims of third parties under copyright, patent or other rights
or interests ("claims").  To the extent that I have any such claims, I
hereby grant to CNRI a nonexclusive, irrevocable, royalty-free, worldwide
license to reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part of the
Python software and its related documentation, or any derivative versions
thereof, at no cost to CNRI or its licensed users, and to authorize others
to do so.

I acknowledge that CNRI may, at its sole discretion, decide whether or not
to incorporate this contribution in the Python software and its related
documentation.  I further grant CNRI permission to use my name and other
identifying information provided to CNRI by me for use in connection with
the Python software and its related documentation.

-------------------------------[ cut here ]---------------------------  
*** Python/compile.c-1.6a1	Fri Apr  7 01:56:18 2000
--- Python/compile.c	Fri Apr  7 02:06:44 2000
***************
*** 121,133 ****
  {
  	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_filename && PyString_Check(co->co_filename))
  		filename = PyString_AsString(co->co_filename);
  	if (co->co_name && PyString_Check(co->co_name))
--- 121,131 ----
  {
  	char buf[500];
  	int lineno = -1;
  	char *filename = "???";
  	char *name = "???";
  
! 	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))