[issue21979] SyntaxError not raised on "0xaor 1"

Mark Dickinson report at bugs.python.org
Mon Jul 14 13:18:15 CEST 2014


Mark Dickinson added the comment:

Surprisingly, this is valid syntax.  Your first line is parsed as:

    0xf or (python is weird in ways)

Because `or` is short-circuiting, its right-hand operand (which is also valid syntactically, being a chained comparison) is never evaluated, so we don't see the `NameErrors` that you might expect.

    >>> python is weird in ways
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'python' is not defined

Your second example is similar.  Closing as 'not a bug'.

----------
nosy: +mark.dickinson
resolution:  -> not a bug
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21979>
_______________________________________


More information about the Python-bugs-list mailing list