[Python-bugs-list] Rare bad tracebacks under -O (PR#77)

tim_one@email.msn.com tim_one@email.msn.com
Sat, 11 Sep 1999 23:05:55 -0400 (EDT)


Full_Name: Tim Peters
Version: 1.5.2
OS: Win95
Submission from: 1cust211.tnt2.bos1.da.uu.net (63.20.160.211)


For a long time I've seen absurd tracebacks under -O (e.g., negative line
numbers), but very rarely.  Since I was looking at tracebacks anyway, thought
I'd track it down.  Turns out to be Guido's only predictable blind spot <wink --
"char" is signed on some non-GvR systems>.  Patch follows.

*** Python/Old/compile.c	Thu Jan 28 09:08:08 1999
--- Python/New/compile.c	Sat Sep 11 22:53:26 1999
***************
*** 3451,3457 ****
  	int addrq;
  {
  	int size = PyString_Size(co->co_lnotab) / 2;
! 	char *p = PyString_AsString(co->co_lnotab);
  	int line = co->co_firstlineno;
  	int addr = 0;
  	while (--size >= 0) {
--- 3451,3457 ----
  	int addrq;
  {
  	int size = PyString_Size(co->co_lnotab) / 2;
! 	unsigned char *p = (unsigned char*)PyString_AsString(co->co_lnotab);
  	int line = co->co_firstlineno;
  	int addr = 0;
  	while (--size >= 0) {