Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

turtledemo/__main__.py: SyntaxError: invalid string prefix else"#fca" #84611

Closed
hroncok mannequin opened this issue Apr 28, 2020 · 12 comments
Closed

turtledemo/__main__.py: SyntaxError: invalid string prefix else"#fca" #84611

hroncok mannequin opened this issue Apr 28, 2020 · 12 comments
Labels
3.8 only security fixes 3.9 only security fixes

Comments

@hroncok
Copy link
Mannequin

hroncok mannequin commented Apr 28, 2020

BPO 40431
Nosy @terryjreedy, @vstinner, @encukou, @hroncok, @miss-islington, @aeros
PRs
  • bpo-40431: Fix syntax typo in turtledemo #19777
  • [3.8] bpo-40431: Fix syntax typo in turtledemo (GH-19777) #19784
  • [3.7] [3.8] bpo-40431: Fix syntax typo in turtledemo (GH-19777) (GH-19784) #19789
  • 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 2020-04-29.03:15:51.848>
    created_at = <Date 2020-04-28.23:29:18.609>
    labels = ['3.8', '3.9']
    title = 'turtledemo/__main__.py: SyntaxError: invalid string prefix else"#fca"'
    updated_at = <Date 2020-05-17.22:38:35.100>
    user = 'https://github.com/hroncok'

    bugs.python.org fields:

    activity = <Date 2020-05-17.22:38:35.100>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-04-29.03:15:51.848>
    closer = 'aeros'
    components = ['Demos and Tools']
    creation = <Date 2020-04-28.23:29:18.609>
    creator = 'hroncok'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40431
    keywords = ['patch']
    message_count = 12.0
    messages = ['367575', '367581', '367583', '367585', '367590', '367607', '367609', '367612', '367618', '367638', '367648', '369154']
    nosy_count = 6.0
    nosy_names = ['terry.reedy', 'vstinner', 'petr.viktorin', 'hroncok', 'miss-islington', 'aeros']
    pr_nums = ['19777', '19784', '19789']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue40431'
    versions = ['Python 3.8', 'Python 3.9']

    @hroncok
    Copy link
    Mannequin Author

    hroncok mannequin commented Apr 28, 2020

    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.

    @hroncok hroncok mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes labels Apr 28, 2020
    @vstinner
    Copy link
    Member

    New changeset 49f70db by Miro Hrončok in branch 'master':
    bpo-40431: Fix syntax typo in turtledemo (GH-19777)
    49f70db

    @vstinner
    Copy link
    Member

    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)?

    @hroncok
    Copy link
    Mannequin Author

    hroncok mannequin commented Apr 29, 2020

    I am OK. I don't see why not to backport it, but I don't care much.

    @vstinner
    Copy link
    Member

    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

    @vstinner vstinner removed 3.7 (EOL) end of life 3.8 only security fixes labels Apr 29, 2020
    @vstinner vstinner removed 3.7 (EOL) end of life 3.8 only security fixes labels Apr 29, 2020
    @aeros
    Copy link
    Contributor

    aeros commented Apr 29, 2020

    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.

    @aeros aeros added 3.7 (EOL) end of life 3.8 only security fixes labels Apr 29, 2020
    @aeros aeros reopened this Apr 29, 2020
    @aeros aeros added 3.7 (EOL) end of life 3.8 only security fixes labels Apr 29, 2020
    @aeros aeros reopened this Apr 29, 2020
    @vstinner
    Copy link
    Member

    If you backport the change, please remove the NEWS entry, since it's not a SyntaxError in 3.7 and 3.8.

    @aeros
    Copy link
    Contributor

    aeros commented Apr 29, 2020

    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.

    @aeros aeros removed 3.7 (EOL) end of life labels Apr 29, 2020
    @aeros
    Copy link
    Contributor

    aeros commented Apr 29, 2020

    New changeset cc011b5 by Kyle Stanley in branch '3.8':
    [3.8] bpo-40431: Fix syntax typo in turtledemo (GH-19777) (bpo-19784)
    cc011b5

    @aeros aeros closed this as completed Apr 29, 2020
    @aeros aeros closed this as completed Apr 29, 2020
    @miss-islington
    Copy link
    Contributor

    New changeset adb1f85 by Miss Islington (bot) in branch '3.7':
    [3.8] bpo-40431: Fix syntax typo in turtledemo (GH-19777) (GH-19784)
    adb1f85

    @vstinner
    Copy link
    Member

    Ok, the typo is now fixed in 3.7, 3.8 and master branches ;-) Thanks Miro for the bug reportand Kyle for the backport.

    @terryjreedy
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants