pythontex icon indicating copy to clipboard operation
pythontex copied to clipboard

Pythontex Warning: "DeprecationWarning: invalid escape sequence \m"

Open julia23m opened this issue 3 years ago • 1 comments

When using pythontex with sagefamily like in the example below, I get the following warning:

This is PythonTeX 0.18

----  Messages for sage:default:default  ----
  /usr/local/texlive/2021/texmf-dist/scripts/pythontex/pythontex_utils.py:231: DeprecationWarning: invalid escape sequence \m
    '''

--------------------------------------------------
PythonTeX:  Sage_Warning - 0 error(s), 0 warning(s)

What does this warning mean and how can I get rid of it?

If I can't get rid of it is there at least a way to prevent emacs from showing this message each time I compile it (after changing the sage code) from emacs?

Minimal Example:

\documentclass{article}

\usepackage[gobble=auto,usefamily=sage]{pythontex}

\begin{document}

\begin{sagecode}
a = 2
b = 3
\end{sagecode}

\(\sage{a}\)

\end{document}

Run pdflatex myfilename.tex and then pythontex myfilename.tex to reproduce the warning (to reproduce it a second time you either have to change the sagecode block or remove the directory pythontex-files-myfilename and then execute pythontex myfilename.tex again).

pdflatex --version
pdfTeX 3.141592653-2.6-1.40.23 (TeX Live 2021)
kpathsea version 6.3.3
Copyright 2021 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.03
sage --version
SageMath version 9.2, Release Date: 2020-10-24

As discussed here

The problem occurs in pythontex_utils.py on line 231. In that line a docstring starts that contains multiple unescaped backslashes leading to accidental escape sequences (not just \m, by the way). In order to fix this, one could either escape each backslash or make the docstring "raw" by prepending an r to the opening quotes.

julia23m avatar Apr 19 '22 17:04 julia23m

I now have the same issue with pythontex3.py and '\s' at three points (lines 557, 1810, 2075).

ejetzer avatar Oct 13 '23 14:10 ejetzer