This commit fixes deprecation warnings that arise from using backslashes
in strings, but not as part of an escape sequence. It will help this
library be used with newer versions of Python.
Examples
Consider the string '\A', previously used in braintree/resource.py:
Also, please note that any invalid escape sequences in Python’s usage
of the backslash in string literals now generate a DeprecationWarning
and in the future this will become a SyntaxError. This behaviour will
happen even if it is a valid escape sequence for a regular expression.
The solution is to use Python’s raw string notation for regular
expression patterns; backslashes are not handled in any special way in a
string literal prefixed with 'r'.
There are no functional changes!
The raw strings used here are equivalent to their originals
on all currently supported versions of Python (including EOL Python 3.5,
3.6).
[x] I understand that unless this is a Draft PR or has a DO NOT MERGE label, this PR is considered to be in a deploy ready state and can be deployed if merged to main
Summary
This commit fixes deprecation warnings that arise from using backslashes in strings, but not as part of an escape sequence. It will help this library be used with newer versions of Python.
Examples
Consider the string
'\A'
, previously used inbraintree/resource.py
:Explanation
For an explanation of the problem (and the recommended solution), see: https://docs.python.org/3/library/re.html
There are no functional changes!
The raw strings used here are equivalent to their originals on all currently supported versions of Python (including EOL Python 3.5, 3.6).
Checklist
nosetests tests/unit
)