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

Fix "except:" statements #14028

Closed
jdemeyer opened this issue Jan 28, 2013 · 12 comments
Closed

Fix "except:" statements #14028

jdemeyer opened this issue Jan 28, 2013 · 12 comments
Assignees
Milestone

Comments

@jdemeyer
Copy link

Replace

except:

by

except StandardError:

(or an other exception where it makes sense)

Also fix some dubious except KeyboardInterrupt which caused for example

Interrupting Gap...
Traceback (most recent call last):
  File "/home/jdemeyer/slow5.py", line 11, in <module>
    __time__=misc.cputime(); __wall__=misc.walltime(); test(); print "Time: CPU %.2f s, Wall: %.2f s"%(misc.cputime(__time__), misc.walltime(__wall__))
  File "/home/jdemeyer/slow5.py", line 9, in test
    assert G.order() == Gamma(n).index() / g.index()
  File "/usr/local/src/sage-5.7.beta1/local/lib/python2.7/site-packages/sage/groups/matrix_gps/matrix_group.py", line 415, in order
    return self.cardinality()
  File "/usr/local/src/sage-5.7.beta1/local/lib/python2.7/site-packages/sage/groups/matrix_gps/matrix_group.py", line 398, in cardinality
    g = self._gap_()
  File "/usr/local/src/sage-5.7.beta1/local/lib/python2.7/site-packages/sage/groups/matrix_gps/matrix_group.py", line 228, in _gap_
    raise NotImplementedError, "Matrix group over %s not implemented."%self.__R
NotImplementedError: Matrix group over Ring of integers modulo 2 not implemented.

or

Interrupting Gap...
Traceback (most recent call last):
  File "/home/jdemeyer/slow5.py", line 11, in <module>
    __time__=misc.cputime(); __wall__=misc.walltime(); test(); print "Time: CPU %.2f s, Wall: %.2f s"%(misc.cputime(__time__), misc.walltime(__wall__))
  File "/home/jdemeyer/slow5.py", line 9, in test
    assert G.order() == Gamma(n).index() / g.index()
  File "/usr/local/src/sage-5.7.beta1/local/lib/python2.7/site-packages/sage/groups/matrix_gps/matrix_group.py", line 415, in order
    return self.cardinality()
  File "/usr/local/src/sage-5.7.beta1/local/lib/python2.7/site-packages/sage/groups/matrix_gps/matrix_group.py", line 400, in cardinality
    return integer.Integer(gap(self).Size())
  File "/usr/local/src/sage-5.7.beta1/local/lib/python2.7/site-packages/sage/interfaces/interface.py", line 590, in __call__
    return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)
  File "/usr/local/src/sage-5.7.beta1/local/lib/python2.7/site-packages/sage/interfaces/gap.py", line 899, in function_call
    return self.new('last')
  File "/usr/local/src/sage-5.7.beta1/local/lib/python2.7/site-packages/sage/interfaces/interface.py", line 266, in new
    return self(code)
  File "/usr/local/src/sage-5.7.beta1/local/lib/python2.7/site-packages/sage/interfaces/interface.py", line 201, in __call__
    return cls(self, x, name=name)
  File "/usr/local/src/sage-5.7.beta1/local/lib/python2.7/site-packages/sage/interfaces/expect.py", line 1285, in __init__
    raise TypeError, x
TypeError: Ctrl-c pressed while running Gap

(note the TypeError!)

Component: misc

Author: Jeroen Demeyer

Reviewer: Volker Braun

Merged: sage-5.7.beta2

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

@jdemeyer

This comment has been minimized.

@jdemeyer

This comment has been minimized.

@jdemeyer jdemeyer changed the title Fix bare "except:" statements Fix "except:" statements Jan 28, 2013
@jdemeyer

This comment has been minimized.

@vbraun
Copy link
Member

vbraun commented Jan 28, 2013

comment:4

Its pretty much a no-brainer. Ready for review?

@jdemeyer
Copy link
Author

comment:5

Replying to @vbraun:

Its pretty much a no-brainer. Ready for review?

Not sure. The following is fairly reproducible when interrupting GAP:

Interrupting Gap...
Exception RuntimeError: RuntimeError('maximum recursion depth exceeded while calling a Python object',) in  ignored
Exception RuntimeError: RuntimeError('maximum recursion depth exceeded while calling a Python object',) in  ignored
Exception RuntimeError: RuntimeError('maximum recursion depth exceeded while calling a Python object',) in  ignored
[...ad infinitum...]

The backtrace at this point (thanks to #14029) is attached.

@jdemeyer
Copy link
Author

Attachment: sage_crash_IAI1or.log

@jdemeyer
Copy link
Author

comment:6

The problem was removing the statement

self._session_number = -1

New patch attached which should fix this. I also changed a few more instances of

except StandardError:

to

except BaseException:

in cases where the except-clause was doing cleanup + re-raise.

@jdemeyer
Copy link
Author

Attachment: 14028_bare_except.patch.gz

@jdemeyer
Copy link
Author

comment:7

Passes all long doctests, so ready for review.

@vbraun
Copy link
Member

vbraun commented Jan 30, 2013

Reviewer: Volker Braun

@vbraun
Copy link
Member

vbraun commented Jan 30, 2013

comment:8

Looks good to me.

@jdemeyer
Copy link
Author

Merged: sage-5.7.beta2

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

3 participants