Dear Sage supporters,
Is there a way to catch a deprecation warning (as one would catch an
error)?
A DeprecationWarning inherits from BaseException, but nonetheless the
following does not work:
sage: def f():
....: try:
....: deprecation('bla')
....: except DeprecationWarning:
....: print "got it!"
....:
sage: f()
/mnt/local/king/SAGE/sage-4.6/local/bin/sage-ipython:1:
DeprecationWarning: bla
#!/usr/bin/env python
Even stranger: When I catch the BaseException then the print statement
is *not* executed.
sage: def f():
....: try:
....: deprecation('bla')
....: except BaseException:
....: print "got it!"
....: return 'what happens?'
....:
sage: f()
'what happens?'
Can you explain to me why I got these results?
Best regards,
Simon
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org