Ask Your Question
1

SageTeX Warning of Sagemath-9.0 on string with Escaped 'S'

asked 2020-02-20 19:26:31 +0100

rana-aerea gravatar image

After I installed SageMath-9.0 (MacApplication), I encountered the following warning in the log of SageTeX compilation.

Console /Applications/SageMath-9.0.app/Contents/Resources/sage/local/lib/python3.7/site-packages/sagetex.py:63: DeprecationWarning: invalid escape sequence \S [re.match(' *\S', line) for line in lines]

I looked through the internet and found a similar situation in some other software.

  • ThiefMaster
  • "invalid escape sequence" DeprecationWarnings with Python 3.6 #646
  • github.com/pallets/jinja/issues/646

I am trying the solution of this page on GitHub.

The relevant part is around line 63 of sagetex.py, which I quote here.

```python
def strip_common_leading_spaces(s):
    lines = s.splitlines()
    lead = min(m.end() for m in
                  [re.match(r' *\S', line) for line in lines]
                  if m is not None) - 1
    return '\n'.join(line[lead:] for line in lines)
```

As in this quotation, I just inserted the letter 'r' to the left of the string on line 63. It is the first line of the deepest indentation in this quotation.

Is this a good solution?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-02-20 21:31:16 +0100

vdelecroix gravatar image

updated 2020-02-20 21:44:03 +0100

Short answer: Yes.

This deprecation warning is most certainly due to the Python 2 to Python 3 switch that happened with Sage version 9.0. Invalid escape sequence (such as "\S") will be treated as error in the future. One could either use two backslashes as in "\\S" (the string "\\" is a single character, the backslash symbol) or use the r as you did (in which case all backslashes will be consider as character, even the linebreak "\n").

edit flag offensive delete link more

Comments

Thank you for precise information. I am happy to know my solution did not harm SageTeX. I feel using double backslash is a better habit. I update the file.

rana-aerea gravatar imagerana-aerea ( 2020-02-21 04:15:12 +0100 )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

Stats

Asked: 2020-02-20 11:55:33 +0100

Seen: 730 times

Last updated: Feb 20 '20