Hello all !
In the following code I consider
f=RealDistribution('chisquared',10).distribution_function
then I provoke and catch an AttributeError on f
. No problems. Then I provoke and catch a TypeError with symbolic_expression(f)
. Once again no problem.
The fun part is that when I provoke the AttributeError and catch AttributeError and TypeError, the next TypeError will not be handled.
f=RealDistribution('chisquared',10).distribution_function
try:
f.blah()
except AttributeError:
pass
try:
f=symbolic_expression(f)
except TypeError:
print "ok"
print "Well, let's do that again"
try:
f.blah()
except AttributeError,TypeError:
pass
try:
f=symbolic_expression(f)
except TypeError:
print "ok"
ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (994, 0))
--------------------------------------------------------------------------- TypeError Traceback (most recent call last)/home/moky/Documents_sources/Unif/Enseignement/pey/phystricks/<ipython console=""> in <module>()
/home/moky/Sage/local/lib/python2.6/site-packages/sage/misc/session.so in sage.misc.session.attach (sage/misc/session.c:1988)()/home/moky/Sage/local/lib/python2.6/site-packages/sage/misc/preparser.pyc in load(filename, globals, attach)
1592 1593 if fpath.endswith('.py'): -> 1594 execfile(fpath, globals) 1595 elif fpath.endswith('.sage'): 1596 exec(preparse_file(open(fpath).read()) + "\n", globals)
/home/moky/Documents_sources/Unif/Enseignement/pey/phystricks/phystricksChiSquared.py in <module>() 19 20 try: ---> 21 f=symbolic_expression(f) 22 except TypeError: 23 print "ok"
/home/moky/Sage/local/lib/python2.6/site-packages/sage/calculus/all.pyc in symbolic_expression(x) 93 return vector(SR,x) 94 else: ---> 95 return SR(x) 96 97 import desolvers
/home/moky/Sage/local/lib/python2.6/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7102)()
/home/moky/Sage/local/lib/python2.6/site-packages/sage/structure/coerce_maps.so in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3254)()
/home/moky/Sage/local/lib/python2.6/site-packages/sage/structure/coerce_maps.so in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3157)()
/home/moky/Sage/local/lib/python2.6/site-packages/sage/symbolic/ring.so in sage.symbolic.ring.SymbolicRing._element_constructor_ (sage/symbolic/ring.cpp:4377)()TypeError:
Any idea to understand or fix this funny behaviour ?
Have a good night Laurent