[Python-checkins] CVS: python/dist/src/Tools/compiler/compiler pyassem.py,1.19,1.19.2.1

Thomas Wouters twouters@users.sourceforge.net
Wed, 27 Jun 2001 07:03:32 -0700


Update of /cvsroot/python/python/dist/src/Tools/compiler/compiler
In directory usw-pr-cvs1:/tmp/cvs-serv31867/Tools/compiler/compiler

Modified Files:
      Tag: release21-maint
	pyassem.py 
Log Message:

Backport Tim's checkin 1.20:

SF bug 430991: wrong co_lnotab
Armin Rigo pointed out that the way the line-# table got built didn't work
for lines generating more than 255 bytes of bytecode.  Fixed as he
suggested, plus corresponding changes to pyassem.py, plus added some long
overdue docs about this subtle table to compile.c.



Index: pyassem.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/compiler/compiler/pyassem.py,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -C2 -r1.19 -r1.19.2.1
*** pyassem.py	2001/04/12 20:21:39	1.19
--- pyassem.py	2001/06/27 14:03:30	1.19.2.1
***************
*** 614,619 ****
      """lnotab
      
!     This class builds the lnotab, which is undocumented but described
!     by com_set_lineno in compile.c.  Here's an attempt at explanation:
  
      For each SET_LINENO instruction after the first one, two bytes are
--- 614,619 ----
      """lnotab
      
!     This class builds the lnotab, which is documented in compile.c.
!     Here's a brief recap:
  
      For each SET_LINENO instruction after the first one, two bytes are
***************
*** 622,627 ****
      instruction for the last SET_LINENO and the current SET_LINENO.
      The second byte is offset in line numbers.  If either offset is
!     greater than 255, multiple two-byte entries are added -- one entry
!     for each factor of 255.
      """
  
--- 622,627 ----
      instruction for the last SET_LINENO and the current SET_LINENO.
      The second byte is offset in line numbers.  If either offset is
!     greater than 255, multiple two-byte entries are added -- see
!     compile.c for the delicate details.
      """
  
***************
*** 658,674 ****
              # for the assignment.
              if line > 0:
!                 while addr > 0 or line > 0:
!                     # write the values in 1-byte chunks that sum
!                     # to desired value
!                     trunc_addr = addr
!                     trunc_line = line
!                     if trunc_addr > 255:
!                         trunc_addr = 255
!                     if trunc_line > 255:
!                         trunc_line = 255
!                     self.lnotab.append(trunc_addr)
!                     self.lnotab.append(trunc_line)
!                     addr = addr - trunc_addr
!                     line = line - trunc_line
                  self.lastline = lineno
                  self.lastoff = self.codeOffset
--- 658,671 ----
              # for the assignment.
              if line > 0:
!                 push = self.lnotab.append
!                 while addr > 255:
!                     push(255); push(0)
!                     addr -= 255
!                 while line > 255:
!                     push(addr); push(255)
!                     line -= 255
!                     addr = 0
!                 if addr > 0 or line > 0:
!                     push(addr); push(line)
                  self.lastline = lineno
                  self.lastoff = self.codeOffset