This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: SyntaxError: invalid token in python2.7/test/
Type: behavior Stage: resolved
Components: Tests Versions: Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, terry.reedy, welker
Priority: normal Keywords:

Created on 2016-10-06 10:13 by welker, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg278180 - (view) Author: Jan Welker (welker) Date: 2016-10-06 10:13
I compiled Python 2.7.12 from source and ran the tests unsuccessful.

Compiling /usr/lib/python2.7/test/ ...
  File "/usr/lib/python2.7/test/", line 80
    self.assertEqual(1 if 1else 0, 1)
SyntaxError: invalid token

It looks like a space (" ") is missing before the else. The same bug can be found in the next line 81.
msg278190 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-10-06 12:59
Thanks for the report! How did you run the test? I think there is something wrong with your installation (or you probably ran the test with the system Python.)

    $ ./python -m test.regrtest test_grammar
    [1/1] test_grammar
    1 test OK.
    [48645 refs]

    $ hg summary
    parent: 104329:59260b38f7cd 
     make 'where' Py_ssize_t
msg278282 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-10-07 22:40
The absence of a space is intentional. See #21642.  Fix applied 2014-06-07.  Hence Berker's guesses.

    def test_float_exponent_tokenization(self):
        # See issue 21642.
        self.assertEqual(1 if 1else 0, 1)
        self.assertEqual(1 if 0else 0, 0)
        self.assertRaises(SyntaxError, eval, "0 if 1Else 0")

On Windows, test passes for 2.7.12 both installed and locally compiled. 

This said, it is possible that there is a compilation problem on some system, especially one that does not match a buildbot.  We can re-open if this is the case.
Date User Action Args
2022-04-11 14:58:37adminsetgithub: 72560
2016-10-07 22:41:00terry.reedysetstatus: pending -> closed
nosy: + terry.reedy
messages: + msg278282

2016-10-06 12:59:40berker.peksagsetstatus: open -> pending

type: behavior

nosy: + berker.peksag
messages: + msg278190
resolution: not a bug
stage: resolved
2016-10-06 10:13:23welkercreate