AntonKueltz / fastecdsa

Python library for fast elliptic curve crypto
https://pypi.python.org/pypi/fastecdsa
The Unlicense
270 stars 78 forks source link

Avoid illegal escape charaters in docstrings #90

Closed akaIDIOT closed 1 year ago

akaIDIOT commented 1 year ago

Ran into deprecation warnings while running tests in my own project concerning escape characters in the docstrings for a number of types / functions in fastecdsa. These deprecation warnings will turn to syntax warnings in Python 3.12 and will be syntax errors further down the line:

A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence), use raw strings for regular expression: re.compile(r"\d+.\d+"). In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning. (Contributed by Victor Stinner in gh-98401.)

(see "Other Language Changes" on Python 3.12's "What's New" page)

The easiest fix for this was to mark the offending docstrings as raw strings. Alternatively, I could turn the offending escape characters into doubly escaped ones (e.g. \equiv into \\equiv) if the maintainers would prefer that solution.

AntonKueltz commented 1 year ago

Thanks for the PR, this appears to also fix some bugs in the RTD math rendering where escape sequences were being incorrectly interpreted.