Ask Your Question

Deprecation warning not showing for .sage script

asked 2020-07-01 18:41:54 +0200

dsejas gravatar image

Hello, Sage Community!

With Sage 9.1, if I write text('$\int$', (0,0)), I get the following deprecation warning:

<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<ipython-input-2-75ff93257356>:1: DeprecationWarning: invalid escape sequence \i
  text('$\int$', (Integer(0),Integer(0)))

Of course, the solution is to use raw strings: text(r'$\int$', (0,0)).

However, if I move that same command to a .sage script--let's call it deprecation.sage---, and I call sage deprecation.sage, I don't see any warning.

Previously, I had written a whole set of Sage and LaTeX commands for writing books and articles with Sage automatic calculations. These commands should check that the code is correct and no warning is issued by Sage. My problem here is that the commands do show every other types of warning, except for this one.

My question is: Is there a way to activate deprecation warnings when executing .sage scripts?

Thanks in advance for your answers!

edit retag flag offensive close merge delete


Your question is too broad: some deprecation warnings are printed when executing .sage scripts. For example: P = Permutations(4); x = P([3,4,2,1]); x.has_left_descent(2, mult='l2r'). The question is, why isn't this one printing? I don't actually see it when I run plain Python, although it seems to be a plain Python deprecation warning.

John Palmieri gravatar imageJohn Palmieri ( 2020-07-01 20:56:40 +0200 )edit

Hello, @John Palmieri! Yes, my question is very broad because I require a very broad approach: I need my Sage and LaTeX commands/environments to catch every single warning issued by Sage or Python, when executing a .sage script.

Specifically, my Sage/LaTeX commands/environments create a global .sage file for a .tex document with the extracted code, much like sageTeX does. Then I need to execute that script, and I need it to print every single warning message issued in the process.

The objective of these commands and environments is to keep the embedded code up-to-date and clean. So, deprecation warnings (or any other kind of warning) being ignored is not a point in favor.

dsejas gravatar imagedsejas ( 2020-07-01 23:36:55 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-07-02 01:38:01 +0200

This is apparently a Python issue, not a Sage issue. Try

PYTHONWARNINGS=always sage deprecation.sage

from a shell prompt. See, also.

edit flag offensive delete link more


This worked perfectly! Thank you very much!

dsejas gravatar imagedsejas ( 2020-07-05 02:02:45 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-07-01 18:41:54 +0200

Seen: 355 times

Last updated: Jul 02 '20