[New-bugs-announce] [issue45984] Error messages for invalid string prefixes and potential attribute accesses

theeshallnotknowethme report at bugs.python.org
Sat Dec 4 17:08:32 EST 2021


New submission from theeshallnotknowethme <nohackingofkrowten at gmail.com>:

In the current version of CPython, this code:

if datetime.now()strftime(...) != "19:50:00": return

produces this error:

  File "<stdin>", line 4
    if datetime.now()strftime(...) != "19:50:00": return
                     ^^^^^^^^
SyntaxError: invalid syntax

This is a potential attribute access, and this bug report proposes it would produce this error instead:

  File "<stdin>", line 4
    if datetime.now()strftime(...) != "19:50:00": return
       ^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a dot?

Also, for string prefixes, this is the current error:

>>> kf'dsdsfddsf'
  File "<stdin>", line 1
    kf'dsdsfddsf'
      ^^^^^^^^^^^
SyntaxError: invalid syntax

This bug report proposes this error instead:

>>> kf'dsdsfddsf'
  File "<stdin>", line 1
    kf'dsdsfddsf'
    ^^
SyntaxError: invalid string prefix 'kf'

----------
components: Parser
messages: 407687
nosy: February291948, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Error messages for invalid string prefixes and potential attribute accesses
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45984>
_______________________________________


More information about the New-bugs-announce mailing list