classification
Title: turtledemo/__main__.py: SyntaxError: invalid string prefix else"#fca"
Type: Stage: resolved
Components: Demos and Tools Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: aeros, hroncok, miss-islington, petr.viktorin, terry.reedy, vstinner
Priority: normal Keywords: patch

Created on 2020-04-28 23:29 by hroncok, last changed 2020-05-17 22:38 by terry.reedy. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19777 merged hroncok, 2020-04-28 23:35
PR 19784 merged aeros, 2020-04-29 02:31
PR 19789 merged miss-islington, 2020-04-29 09:24
Messages (12)
msg367575 - (view) Author: Miro Hrončok (hroncok) * Date: 2020-04-28 23:29
With Python 3.9.0a6 we get the following syntax error when bytecompiling the standard library in Fedora:


Compiling '/usr/lib64/python3.9/turtledemo/__main__.py'...
***   File "/usr/lib64/python3.9/turtledemo/__main__.py", line 275
    bg="#d00" if clear == NORMAL else"#fca")
                                    ^
SyntaxError: invalid string prefix


I've looked and the bad code is there for all branches, but only with 3.9.0a6 I get the SyntaxError.

I wonder whether this is a know new SyntaxError or not. This "worked" with 3.9.0a5:

>>> "yes" if False else"no"
'no'

Happy to submit a PR for turtledemo.
msg367581 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-29 00:00
New changeset 49f70db83e2c62ad06805927f53f6c3e8f4b798e by Miro Hrončok in branch 'master':
bpo-40431: Fix syntax typo in turtledemo (GH-19777)
https://github.com/python/cpython/commit/49f70db83e2c62ad06805927f53f6c3e8f4b798e
msg367583 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-29 00:01
I don't think that it's worth it to backport the change to 3.7 and 3.8: in Python 3.7 and 3.8, the code is accepted.

I also reported the issue to: https://bugs.python.org/issue40334#msg367580

Miro: are you ok to close the issue (not backport)?
msg367585 - (view) Author: Miro Hrončok (hroncok) * Date: 2020-04-29 00:07
I am OK. I don't see why not to backport it, but I don't care much.
msg367590 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-29 00:19
> I am OK. I don't see why not to backport it, but I don't care much.

Python 3.7 and 3.8 are not broken, so there is no need to fix them :-) Thanks for the fix.

I reported the issue to:
https://bugs.python.org/issue40246#msg367587
msg367607 - (view) Author: Kyle Stanley (aeros) * (Python committer) Date: 2020-04-29 01:34
> I don't think that it's worth it to backport the change to 3.7 and 3.8: in Python 3.7 and 3.8, the code is accepted.

> Python 3.7 and 3.8 are not broken, so there is no need to fix them :-)

I think we could very reasonably change  `else"#fca"` -> `else "#fca"` on the current bugfix branches, or at least 3.8. Even when it doesn't cause a syntax error and the attempted prefix is ignored, it's still more syntactically correct compared to attempting to use an "e-string" (which of course doesn't exist) and has nearly zero cost on our end to fix. 

While it's a low priority issue since it doesn't raise an error, that doesn't necessarily mean it's correct. In the latest stable version of the stdlib, we should aim to provide a good example IMO, especially if it comes at practically zero cost to us.
msg367609 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-29 01:37
If you backport the change, please remove the NEWS entry, since it's not a SyntaxError in 3.7 and 3.8.
msg367612 - (view) Author: Kyle Stanley (aeros) * (Python committer) Date: 2020-04-29 02:06
Victor Stinner wrote:
> If you backport the change, please remove the NEWS entry, since it's not a SyntaxError in 3.7 and 3.8.

Good point. In that case, I'll do a manual backport of the PR just to 3.8 and skip the news entry. As mentioned above, I think most of the value in fixing it when the SyntaxError isn't present is mainly just for providing a good example in the latest stable version of the stdlib, so I don't think there would be much additional value in also backporting it to 3.7.
msg367618 - (view) Author: Kyle Stanley (aeros) * (Python committer) Date: 2020-04-29 03:11
New changeset cc011b5190b63f0be561ddec38fc4cd9e60cbf6a by Kyle Stanley in branch '3.8':
[3.8] bpo-40431: Fix syntax typo in turtledemo (GH-19777) (#19784)
https://github.com/python/cpython/commit/cc011b5190b63f0be561ddec38fc4cd9e60cbf6a
msg367638 - (view) Author: miss-islington (miss-islington) Date: 2020-04-29 09:42
New changeset adb1f853482e75e81ae0ae7307318a1051ca46b5 by Miss Islington (bot) in branch '3.7':
[3.8] bpo-40431: Fix syntax typo in turtledemo (GH-19777) (GH-19784)
https://github.com/python/cpython/commit/adb1f853482e75e81ae0ae7307318a1051ca46b5
msg367648 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-29 14:37
Ok, the typo is now fixed in 3.7, 3.8 and master branches ;-) Thanks Miro for the bug reportand Kyle for the backport.
msg369154 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-05-17 22:38
I believe the file was synchronized across versions as new features have not recently been added. Backporting the fix to my typo should keep it that way.  This is an example of why code review even of patches that 'work' is a good thing.
History
Date User Action Args
2020-05-17 22:38:35terry.reedysetnosy: + terry.reedy
messages: + msg369154
2020-04-29 14:37:55vstinnersetmessages: + msg367648
2020-04-29 09:42:31miss-islingtonsetmessages: + msg367638
2020-04-29 09:24:33miss-islingtonsetnosy: + miss-islington

pull_requests: + pull_request19112
2020-04-29 03:15:51aerossetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-04-29 03:11:24aerossetmessages: + msg367618
2020-04-29 02:31:00aerossetpull_requests: + pull_request19107
2020-04-29 02:07:55aerossetversions: - Python 3.7
2020-04-29 02:06:42aerossetmessages: + msg367612
2020-04-29 01:37:05vstinnersetmessages: + msg367609
2020-04-29 01:34:46aerossetstatus: closed -> open

versions: + Python 3.7, Python 3.8
nosy: + aeros

messages: + msg367607
resolution: fixed -> (no value)
stage: resolved -> patch review
2020-04-29 00:19:56vstinnersetstatus: open -> closed
versions: - Python 3.7, Python 3.8
messages: + msg367590

resolution: fixed
stage: patch review -> resolved
2020-04-29 00:07:18hroncoksetmessages: + msg367585
2020-04-29 00:01:10vstinnersetmessages: + msg367583
2020-04-29 00:00:10vstinnersetmessages: + msg367581
2020-04-28 23:35:22hroncoksetkeywords: + patch
stage: patch review
pull_requests: + pull_request19097
2020-04-28 23:29:18hroncokcreate