Skip to content

Python 3.6+ DeprecationWarning / Python 3.8 SyntaxWarnings #99

Closed
@Harmon758

Description

@Harmon758

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

https://docs.python.org/3.6/whatsnew/changelog.html, https://bugs.python.org/issue27364, https://hg.python.org/cpython/rev/38802c38cfe1, python/cpython@110b6fe

Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import emoji
C:\Program Files\Python36\lib\site-packages\emoji\core.py:43: DeprecationWarning: invalid escape sequence \+
  pattern = re.compile(u'(%s[a-zA-Z0-9\+\-_&.ô’Åéãíç()!#*]+%s)' % delimiters)

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

The compiler now produces a SyntaxWarning when identity checks (is and is not) are used with certain types of literals (e.g. strings, ints). These can often work by accident in CPython, but are not guaranteed by the language spec. The warning advises users to use equality tests (== and !=) instead.

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

https://bugs.python.org/issue34850, python/cpython#9642, python/cpython@3bcbedc

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 emoji
C:\Program Files\Python38\lib\site-packages\emoji\core.py:43: SyntaxWarning: invalid escape sequence \+
  pattern = re.compile(u'(%s[a-zA-Z0-9\+\-_&.ô’Åéãíç()!#*]+%s)' % delimiters)
C:\Program Files\Python38\lib\site-packages\emoji\core.py:22: SyntaxWarning: "is" with a literal. Did you mean "=="?
  PY2 = sys.version_info[0] is 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions