Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polymake interface: Bug in interrupt handling - expect_list #22702

Open
mkoeppe opened this issue Mar 28, 2017 · 7 comments
Open

polymake interface: Bug in interrupt handling - expect_list #22702

mkoeppe opened this issue Mar 28, 2017 · 7 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 28, 2017

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

Depends on #22452

CC: @simon-king-jena

Component: interfaces

Keywords: polymake

Issue created by migration from https://trac.sagemath.org/ticket/22702

@mkoeppe mkoeppe added this to the sage-8.0 milestone Mar 28, 2017
@jdemeyer
Copy link
Contributor

comment:1

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.

@jdemeyer jdemeyer removed this from the sage-8.0 milestone Mar 30, 2017
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 30, 2017

comment:2

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

@jdemeyer
Copy link
Contributor

comment:3

Replying to @mkoeppe:

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

Well, then mention that on the ticket!

@jdemeyer jdemeyer reopened this Mar 30, 2017
@jdemeyer jdemeyer added this to the sage-8.0 milestone Mar 30, 2017
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 30, 2017

comment:4

Thanks, done.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 30, 2017

Dependencies: #22452

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 30, 2017

Changed keywords from none to polymake

@mkoeppe

This comment has been minimized.

@mkoeppe mkoeppe removed this from the sage-8.0 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants