Skip to content

Use raw strings for regex patterns#5

Merged
paulovn merged 1 commit into
paulovn:masterfrom
Harmon758:regex-raw-string-usage
Jul 26, 2019
Merged

Use raw strings for regex patterns#5
paulovn merged 1 commit into
paulovn:masterfrom
Harmon758:regex-raw-string-usage

Conversation

@Harmon758
Copy link
Copy Markdown

Python 3.8.0b2 (tags/v3.8.0b2:21dd01d, Jul  4 2019, 16:00:09) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import aiml
C:\Program Files\Python38\lib\site-packages\aiml\Kernel.py:1002: SyntaxWarning: invalid escape sequence \s
  elem[2] = re.sub("\s+", " ", elem[2])
C:\Program Files\Python38\lib\site-packages\aiml\PatternMgr.py:30: SyntaxWarning: invalid escape sequence \|
  punctuation = "\"`~!@#$%^&*()-_=+[{]}\|;:',<.>/?"
C:\Program Files\Python38\lib\site-packages\aiml\PatternMgr.py:32: SyntaxWarning: invalid escape sequence \s
  self._whitespaceRE = re.compile("\s+", re.UNICODE)

A backslash-character pair that is not a valid escape sequence generates a DeprecationWarning since Python 3.6. In Python 3.8 it generates a SyntaxWarning instead.

https://docs.python.org/3.8/whatsnew/3.8.html

Changed in version 3.6: Unrecognized escape sequences produce a DeprecationWarning.

Changed in version 3.8: Unrecognized escape sequences produce a SyntaxWarning. In some future version of Python they will be a SyntaxError.

https://docs.python.org/3.8/reference/lexical_analysis.html

https://bugs.python.org/issue32912, python/cpython#9652, python/cpython@6543912

@paulovn paulovn merged commit 2206a40 into paulovn:master Jul 26, 2019
@paulovn
Copy link
Copy Markdown
Owner

paulovn commented Jul 26, 2019

Thanks for this -- this is a leftover from the original 2.7 code

@Harmon758 Harmon758 deleted the regex-raw-string-usage branch July 27, 2019 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants