Ha ha. In misc/superseded.py the function warning just reset all filters
each time it is called
def warning(...):
_check_trac_number(trac_number)
message += '\n'
message += 'See http://trac.sagemath.org/'+ str(trac_number) + '
for details.'
resetwarnings()
# Stack level 3 to get the line number of the code which called
# the deprecated function which called this function.
warn(message, warning_class, stacklevel)
As it is used everywhere the filterwarnings just not works. I just
removed the "resetwarnings()" line and I was able to get an error with
your example.
Was it done on purpose?!
Vincent
On 08/04/16 13:07, João Pedro Cruz wrote:
Hello,
I was expecting the following to catch the DeprecationWarning
import warnings
warnings.filterwarnings('error',category=DeprecationWarning)
try:
print (exp(x)*exp(3*x)).simplify_exp() #example with exp function
except DeprecationWarning:
print 'MegBook.py say: exercise needs review!'
but it does not. I still got
DeprecationWarning: simplify_exp is deprecated. Please use
canonicalize_radical instead.
See http://trac.sagemath.org/11912 for details.
print (exp(x)*exp(_sage_const_3 *x)).simplify_exp() #example with exp
function
*How can we catch this "type" of* DeprecationWarning ?
I've checked
https://github.com/sagemath/sage/blob/master/src/sage/misc/superseded.py
but reached no conclusion.
I appreciate help,
Thank you.
Pedro
The following works easy:
try:
raise DeprecationWarning
except DeprecationWarning :
print 'Got it'
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.