Skip to content

"invalid escape sequence" DeprecationWarnings with Python 3.6 #646

Closed

Description

@The-Compiler

I get these while running my project's testsuite with all warnings turned on and Python 3.6:

.../jinja2/nodes.py:716: DeprecationWarning: invalid escape sequence \s
         """
       
.../jinja2/runtime.py:111: DeprecationWarning: invalid escape sequence \s
         """
       
.../jinja2/lexer.py:294: DeprecationWarning: invalid escape sequence \s
         """
       
.../jinja2/lexer.py:503: DeprecationWarning: invalid escape sequence \-
         (c('(?:\-%s\s*|%s)%s' % (
       
.../jinja2/lexer.py:511: DeprecationWarning: invalid escape sequence \-
         (c('\-%s\s*|%s' % (
       
.../jinja2/lexer.py:518: DeprecationWarning: invalid escape sequence \s
         (c('(.*?)((?:\s*%s\-|%s)\s*endraw\s*(?:\-%s\s*|%s%s))' % (

It looks like it's mostly \s in (non-raw) docstrings and \- in regexes. For some odd reason I can't reproduce this when running pylint's testsuite with pytest-warnings though, so I don't know if there's more.

Activity

  1. ThiefMaster commented on Jan 8, 2017

    @ThiefMaster
    Member

    I think those strings should be r'...' raw strings to avoid exactly such warnings

  2. ThiefMaster commented on Jan 8, 2017

    @ThiefMaster
    Member

    FWIW, I don't think any \ is needed for the - - outside [] the dash has no special meaning.

  3. added a commit that references this issue on Jan 8, 2017
    be16786
  4. MartinThoma commented on Nov 19, 2018

    @MartinThoma

    pip3 install jinja --user --upgrade solved it for me.

  5. abrahamrhoffman commented on Oct 25, 2019

    @abrahamrhoffman

    raw string conversion ftw! I came here looking for a solution to my linting problems :) thanks for the tip!

    r"awk -F\my_string '{print $1}'"
    

    not

    "awk -F\my_string '{print $1}'"
    
  6. added a commit that references this issue on Jun 5, 2020
  7. locked as resolved and limited conversation to collaborators on Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions