Question about a deprecation warning

61 views
Skip to first unread message

John H Palmieri

unread,
Jul 1, 2020, 3:06:43 PM7/1/20
to sage-support
This puzzles me: evaluating '\i' in Python 3 just gives '\i'. Same with IPython. Evaluating it in Sage prints many warning messages: the following is from a fresh Sage session, and I only evaluated '\i' once, despite the appearance:


% sage
┌────────────────────────────────────────────────────────────────────┐
SageMath version 9.2.beta2, Release Date: 2020-06-26              
Using Python 3.7.7. Type "help()" for help.                        
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Warning: this is a prerelease version, and it may be unstable.    
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage
: '\i'<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
sage
: '\i'
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<ipython-input-1-aeb68ac32d93>:1: DeprecationWarning: invalid escape sequence \i
 
'\i'
'\\i'
sage
:


Why so many deprecation warnings? I think they're coming from plain Python; why doesn't Python print the warnings?

--
John

Antonio Rojas

unread,
Jul 1, 2020, 5:22:49 PM7/1/20
to sage-support


El miércoles, 1 de julio de 2020, 21:06:43 (UTC+2), John H Palmieri escribió:

Why so many deprecation warnings? I think they're coming from plain Python; why doesn't Python print the warnings?



Because python ignores deprecation warnings, https://docs.python.org/3/library/warnings.html#default-warning-filter 

John H Palmieri

unread,
Jul 1, 2020, 7:39:12 PM7/1/20
to sage-support
Thanks, that's helpful. But why does Sage print the warning so many times? If I turn on Python's deprecation warnings, I just see one warning message, not six of them.

John H Palmieri

unread,
Jul 1, 2020, 8:19:58 PM7/1/20
to sage-support
I guess this is in turn an IPython thing, although I don't know why IPython prints the warning 6 times, and also repeats my original command. With warnings enabled, I evaluated '\i' once:

% PYTHONWARNINGS=always sage --ipython
...
IPython 5.8.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python'
s own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: '\i'<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
In [1]: '\i'

<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<ipython-input-1-aeb68ac32d93>:1: DeprecationWarning: invalid escape sequence \i
 
'\i'
Out[1]: '\\i'



Kwankyu

unread,
Jul 10, 2020, 2:43:36 AM7/10/20
to sage-support
Because of the preparser?

John H Palmieri

unread,
Jul 10, 2020, 2:31:15 PM7/10/20
to sage-support
Does IPython have a preparser?

Kwankyu

unread,
Jul 12, 2020, 5:38:23 AM7/12/20
to sage-support
On Saturday, July 11, 2020 at 3:31:15 AM UTC+9 John H Palmieri wrote:
Does IPython have a preparser?

I suspected Sage's preparser. I was wrong. You are right: (even out of Sage)

Hera:~$ PYTHONWARNINGS=always ipython
Python 3.8.3 (default, May 27 2020, 20:54:22) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.15.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: '\i'                                                                    
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
Reply all
Reply to author
Forward
0 new messages