Skip to content

DeprecationWarning not reported for invalid escape sequences #72540

Closed

Description

@skirpichev
mannequin
BPO 28354
Nosy @serhiy-storchaka, @skirpichev
Superseder
  • bpo-28128: Improve the warning message for invalid escape sequences
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2016-10-04.09:06:49.730>
    created_at = <Date 2016-10-04.09:00:39.484>
    labels = ['interpreter-core']
    title = 'DeprecationWarning not reported for invalid escape sequences'
    updated_at = <Date 2016-10-04.09:06:49.728>
    user = 'https://github.com/skirpichev'

    bugs.python.org fields:

    activity = <Date 2016-10-04.09:06:49.728>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-10-04.09:06:49.730>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2016-10-04.09:00:39.484>
    creator = 'Sergey.Kirpichev'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 28354
    keywords = []
    message_count = 2.0
    messages = ['278020', '278023']
    nosy_count = 2.0
    nosy_names = ['serhiy.storchaka', 'Sergey.Kirpichev']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '28128'
    type = None
    url = 'https://bugs.python.org/issue28354'
    versions = ['Python 3.6']

    Activity

    1. skirpichev commented on Oct 4, 2016

      skirpichevmannequin
      MannequinAuthor
      We know from release notes, that "A backslash-character pair that is not a valid escape sequence now generates a DeprecationWarning".  Sometimes it's true:
      $ python -W error
      Python 3.6.0b1+ (default, Oct  4 2016, 08:47:51) 
      [GCC 4.9.2] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      >>> "xxx" != "hello \world"
      DeprecationWarning: invalid escape sequence '\w'

      But shouldn't DeprecationWarning be in the following case as well?

      $ cat a.py 
      def f(s):
          return s != "hello \world"
      $ cat b.py 
      import a
      print(a.f("xxx"))
      $ python b.py 
      True
      $ python -W error b.py 
      True
    2. serhiy-storchaka commented on Oct 4, 2016

      @serhiy-storchaka
      Member

      See bpo-28128.

      A warning should be emitted when you compile the code, but it shouldn't be emitted when you import compiled module.

    3. transferred this issue fromon Apr 10, 2022
    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

      interpreter-core(Objects, Python, Grammar, and Parser dirs)

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions