Opened 4 years ago

Last modified 4 years ago

#22702 new defect

polymake interface: Bug in interrupt handling - expect_list

Reported by: mkoeppe Owned by:
Priority: major Milestone: sage-8.0
Component: interfaces Keywords: polymake
Cc: SimonKing Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #22452 Stopgaps:

Status badges

Description (last modified by mkoeppe)

Following up on #22452 (Create a Polymake pexpect interface):

In polymake.py, Polymake._keyboard_interrupt passes a bad first argument in the line

i = self._expect.expect_list(self._prompt, timeout=1)

This leads to:

/Users/mkoeppe/s/sage/sage-rebasing/another-local-sans-autotools/lib/python2.7/site-packages/sage/interfaces/polymake.pyc in _eval_line(self, line, allow_use_file, wait_for_prompt, restart_if_needed, **kwds)
    919                         except (TypeError, RuntimeError):
    920                             pass
--> 921                         return self._eval_line(line,allow_use_file=allow_use_file, wait_for_prompt=wait_for_prompt, restart_if_needed=False, **kwds)
    922                 raise_(RuntimeError, "%s\nError evaluating %s in %s"%(msg, line, self), sys.exc_info()[2])
    923 

/Users/mkoeppe/s/sage/sage-rebasing/another-local-sans-autotools/lib/python2.7/site-packages/sage/interfaces/polymake.pyc in _eval_line(self, line, allow_use_file, wait_for_prompt, restart_if_needed, **kwds)
   1052                 out = ''
   1053         except KeyboardInterrupt:
-> 1054             self._keyboard_interrupt()
   1055             raise KeyboardInterrupt("Ctrl-c pressed while running %s"%self)
   1056         for w in p_warnings:

/Users/mkoeppe/s/sage/sage-rebasing/another-local-sans-autotools/lib/python2.7/site-packages/sage/interfaces/polymake.pyc in _keyboard_interrupt(self)
    446                 raise pexpect.ExceptionPexpect("THIS IS A BUG -- PLEASE REPORT. This should never happen.\n" + msg)
    447             sleep(0.1)
--> 448             i = self._expect.expect_list(self._prompt, timeout=1)
    449             if i==0:
    450                 break

/Users/mkoeppe/s/sage/sage-rebasing/another-local-sans-autotools/lib/python2.7/site-packages/pexpect/spawnbase.pyc in expect_list(self, pattern_list, timeout, searchwindowsize, async)
    343             return expect_async(exp, timeout)
    344         else:
--> 345             return exp.expect_loop(timeout)
    346 
    347     def expect_exact(self, pattern_list, timeout=-1, searchwindowsize=-1,

/Users/mkoeppe/s/sage/sage-rebasing/another-local-sans-autotools/lib/python2.7/site-packages/pexpect/expect.pyc in expect_loop(self, timeout)
     89             spawn.buffer = spawn.string_type()  # Treat buffer as new data
     90             while True:
---> 91                 idx = self.new_data(incoming)
     92                 # Keep reading until exception or return.
     93                 if idx is not None:

/Users/mkoeppe/s/sage/sage-rebasing/another-local-sans-autotools/lib/python2.7/site-packages/pexpect/expect.pyc in new_data(self, data)
     17         incoming = spawn.buffer + data
     18         freshlen = len(data)
---> 19         index = searcher.search(incoming, freshlen, self.searchwindowsize)
     20         if index >= 0:
     21             spawn.buffer = incoming[searcher.end:]

/Users/mkoeppe/s/sage/sage-rebasing/another-local-sans-autotools/lib/python2.7/site-packages/pexpect/expect.pyc in search(self, buffer, freshlen, searchwindowsize)
    285             searchstart = max(0, len(buffer) - searchwindowsize)
    286         for index, s in self._searches:
--> 287             match = s.search(buffer, searchstart)
    288             if match is None:
    289                 continue

AttributeError: 'str' object has no attribute 'search'
sage: 
sage: %debug
> /Users/mkoeppe/s/sage/sage-rebasing/another-local-sans-autotools/lib/python2.7/site-packages/pexpect/expect.py(287)search()
    285             searchstart = max(0, len(buffer) - searchwindowsize)
    286         for index, s in self._searches:
--> 287             match = s.search(buffer, searchstart)
    288             if match is None:
    289                 continue

ipdb> print s
p
ipdb> print type(s)
<type 'str'>

I do not know how to reproduce this consistently. It involves pressing C-c at the right moment.

See also: #22710: Meta-ticket: polymake

Change History (4)

comment:1 Changed 4 years ago by jdemeyer

  • Milestone changed from sage-8.0 to sage-duplicate/invalid/wontfix
  • Resolution set to invalid
  • Status changed from new to closed

There is no polymake.py in Sage. You must be running code from some other branch. Set that other branch to needs_work if there are issues.

comment:2 follow-up: Changed 4 years ago by mkoeppe

No, I want this to be a follow up ticket. The original ticket is good enough for production work already.

comment:3 in reply to: ↑ 2 Changed 4 years ago by jdemeyer

  • Milestone changed from sage-duplicate/invalid/wontfix to sage-8.0
  • Resolution invalid deleted
  • Status changed from closed to new

Replying to mkoeppe:

No, I want this to be a follow up ticket.

Well, then mention that on the ticket!

comment:4 Changed 4 years ago by mkoeppe

  • Dependencies set to #22452
  • Description modified (diff)
  • Keywords polymake added

Thanks, done.

Note: See TracTickets for help on using tickets.