[Bug 1477472] [NEW] Failure of ANSI library when reciving "Erase in Line" ANSI escape code

Martyn Welch martyn at welchs.me.uk
Thu Jul 23 09:31:45 UTC 2015


Public bug reported:

There is a bug in the 12.04 pexpect package that results in the ANSI
library throwing an exception when it receives the "Erase in Line"
escape code ("ESC[2K"):

Traceback (most recent call last):
  File "./pexpect-check.py", line 12, in <module>
    screen.write("%c[2K" %(0x1B))
  File "/usr/lib/python2.7/dist-packages/ANSI.py", line 257, in write
    self.process(c)
  File "/usr/lib/python2.7/dist-packages/ANSI.py", line 248, in process
    self.state.process(c)
  File "/usr/lib/python2.7/dist-packages/FSM.py", line 223, in process
    self.action (self)
  File "/usr/lib/python2.7/dist-packages/ANSI.py", line 118, in DoEraseLine
    if arg == 0:
NameError: global name 'arg' is not defined


The following test code can be used to test for this failure:

#!/usr/bin/env python
import sys
import ANSI

print "Testing operation of \"DoEraseLine\" in ANSI library: ",

screen = ANSI.ANSI(25,80)

screen.write("This line should be deleted")
#print screen.pretty()

try:
	screen.write("%c[2K" %(0x1B))
	#print screen.pretty()

except:
	print "FAIL"
	sys.exit(1)

print "PASS"
sys.exit(0)


This has been fixed in later versions of pexpect, but is broken in the (still supported?) version in precise. The minimal patch required to resolve this issue is:

--- ANSI.py.orig	2015-07-23 10:22:11.561742106 +0100
+++ ANSI.py	2015-07-23 10:22:29.841339490 +0100
@@ -114,6 +114,7 @@
 
 def DoEraseLine (fsm):
 
+    arg = int(fsm.memory.pop())
     screen = fsm.memory[0]
     if arg == 0:
         screen.end_of_line()

** Affects: pexpect (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to pexpect in Ubuntu.
https://bugs.launchpad.net/bugs/1477472

Title:
  Failure of ANSI library when reciving "Erase in Line" ANSI escape code

Status in pexpect package in Ubuntu:
  New

Bug description:
  There is a bug in the 12.04 pexpect package that results in the ANSI
  library throwing an exception when it receives the "Erase in Line"
  escape code ("ESC[2K"):

  Traceback (most recent call last):
    File "./pexpect-check.py", line 12, in <module>
      screen.write("%c[2K" %(0x1B))
    File "/usr/lib/python2.7/dist-packages/ANSI.py", line 257, in write
      self.process(c)
    File "/usr/lib/python2.7/dist-packages/ANSI.py", line 248, in process
      self.state.process(c)
    File "/usr/lib/python2.7/dist-packages/FSM.py", line 223, in process
      self.action (self)
    File "/usr/lib/python2.7/dist-packages/ANSI.py", line 118, in DoEraseLine
      if arg == 0:
  NameError: global name 'arg' is not defined

  
  The following test code can be used to test for this failure:

  #!/usr/bin/env python
  import sys
  import ANSI

  print "Testing operation of \"DoEraseLine\" in ANSI library: ",

  screen = ANSI.ANSI(25,80)

  screen.write("This line should be deleted")
  #print screen.pretty()

  try:
  	screen.write("%c[2K" %(0x1B))
  	#print screen.pretty()

  except:
  	print "FAIL"
  	sys.exit(1)

  print "PASS"
  sys.exit(0)

  
  This has been fixed in later versions of pexpect, but is broken in the (still supported?) version in precise. The minimal patch required to resolve this issue is:

  --- ANSI.py.orig	2015-07-23 10:22:11.561742106 +0100
  +++ ANSI.py	2015-07-23 10:22:29.841339490 +0100
  @@ -114,6 +114,7 @@
   
   def DoEraseLine (fsm):
   
  +    arg = int(fsm.memory.pop())
       screen = fsm.memory[0]
       if arg == 0:
           screen.end_of_line()

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/pexpect/+bug/1477472/+subscriptions



More information about the foundations-bugs mailing list