Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
julia23m opened this issue Apr 19, 2022 · 1 comment
Open

Comments

@julia23m
Copy link

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.

jackschmidt added a commit to jackschmidt/pythontex that referenced this issue Apr 30, 2022
As suggested in

https://tex.stackexchange.com/questions/634981/pythontex-warning/640760

and reported on github as gpoore#196 -- the docstring contains latex
macros, but python interprets them as escape sequences. Use a python
raw string, r''' ... ''', in order to avoid this interpretation.
@ejetzer
Copy link

ejetzer commented Oct 13, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants