Ask Your Question
1

Deprecation warning not showing for .sage script

asked 4 years ago

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!

Preview: (hide)

Comments

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 ( 4 years ago )
1

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 ( 4 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 4 years ago

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

PYTHONWARNINGS=always sage deprecation.sage

from a shell prompt. See https://docs.python.org/3/library/war..., also.

Preview: (hide)
link

Comments

This worked perfectly! Thank you very much!

dsejas gravatar imagedsejas ( 4 years ago )

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

Stats

Asked: 4 years ago

Seen: 610 times

Last updated: Jul 02 '20