GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-108843: fix ast.unparse for f-string with many quotes by hauntsaninja · Pull Request #108981 · python/cpython

Conversation

@hauntsaninja

@hauntsaninja hauntsaninja commented Sep 6, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

The core of the issue here is the fallback to repr in _str_literal_helper when we can't find a workable quote type. This works fine for single strings, but doesn't work well for joined strings (since earlier values of the joined string may have been written assuming a different quote). Therefore, in the bad case, we go back and force use of repr with a single quote for all parts of the joined string. The assert checks that repr continues to work the way we expect it to work.

  • Issue: ast.unparse is not working correctly for strings with multiple quotes #108843

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hauntsaninja
pythongh-108843: fix ast.unparse for f-string with many quotes
a1201a5
@hauntsaninja
hauntsaninja requested a review from isidentical as a code owner September 6, 2023 06:15
@bedevere-bot bedevere-bot added the awaiting core review label Sep 6, 2023
@bedevere-bot bedevere-bot mentioned this pull request Sep 6, 2023
ast.unparse is not working correctly for strings with multiple quotes #108843
Closed
@hauntsaninja
hauntsaninja requested a review from sunmy2019 September 6, 2023 06:16
@blurb-it
📜🤖 Added by blurb_it.
75ab646
@sunmy2019
sunmy2019 requested review from Yhg1s and pablogsal September 6, 2023 06:20
sunmy2019
sunmy2019 reviewed Sep 6, 2023
View reviewed changes
Comment thread Lib/ast.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hauntsaninja
feedback
7fb718a
sunmy2019
sunmy2019 approved these changes Sep 17, 2023
View reviewed changes
@sunmy2019 sunmy2019 added the needs backport to 3.12 only security fixes label Sep 17, 2023
@pablogsal
pablogsal merged commit 23f9f6f into python:main Sep 18, 2023
@miss-islington

miss-islington commented Sep 18, 2023

Copy link
Copy Markdown
Contributor

Thanks @hauntsaninja for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting core review label Sep 18, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 18, 2023
@hauntsaninja @miss-islington
pythongh-108843: fix ast.unparse for f-string with many quotes (pytho…
22b3431
…nGH-108981)

(cherry picked from commit 23f9f6f)

Co-authored-by: Shantanu <[email protected]>
@pablogsal

pablogsal commented Sep 18, 2023

Copy link
Copy Markdown
Member

Thanks a lot @hauntsaninja !

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented Sep 18, 2023

Copy link
Copy Markdown

GH-109541 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Sep 18, 2023
@bedevere-bot

bedevere-bot commented Sep 18, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Ubuntu Shared 3.x has failed when building commit 23f9f6f.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/506/builds/5890) and take a look at the build logs.
  4. Check if the failure is related to this commit (23f9f6f) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/506/builds/5890

Failed tests:

  • test_threading

Failed subtests:

  • test_4_daemon_threads - test.test_threading.ThreadJoinOnShutdown.test_4_daemon_threads

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_threading.py", line 1168, in test_4_daemon_threads
    rc, out, err = assert_python_ok('-c', script)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/support/script_helper.py", line 166, in assert_python_ok
    return _assert_python(True, *args, **env_vars)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/support/script_helper.py", line 151, in _assert_python
    res.fail(cmd_line)
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/support/script_helper.py", line 76, in fail
    raise AssertionError("Process return code is %d\n"
AssertionError: Process return code is -11
command line: ['/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/python', '-X', 'faulthandler', '-I', '-c', "if True:\n            import os\n            import random\n            import sys\n            import time\n            import threading\n\n            thread_has_run = set()\n\n            def random_io():\n                '''Loop for a while sleeping random tiny amounts and doing some I/O.'''\n                import test.test_threading as mod\n                while True:\n                    with open(mod.__file__, 'rb') as in_f:\n                        stuff = in_f.read(200)\n                        with open(os.devnull, 'wb') as null_f:\n                            null_f.write(stuff)\n                            time.sleep(random.random() / 1995)\n                    thread_has_run.add(threading.current_thread())\n\n            def main():\n                count = 0\n                for _ in range(40):\n                    new_thread = threading.Thread(target=random_io)\n                    new_thread.daemon = True\n                    new_thread.start()\n                    count += 1\n                while len(thread_has_run) < count:\n                    time.sleep(0.001)\n                # Trigger process shutdown\n                sys.exit(0)\n\n            main()\n            "]
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Yhg1s pushed a commit that referenced this pull request Sep 18, 2023
@miss-islington @hauntsaninja
[3.12] gh-108843: fix ast.unparse for f-string with many quotes (GH-1…
2401b98
…08981) (#109541)

gh-108843: fix ast.unparse for f-string with many quotes (GH-108981)
(cherry picked from commit 23f9f6f)

Co-authored-by: Shantanu <[email protected]>
@bedevere-bot

bedevere-bot commented Sep 18, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot ARM Raspbian 3.x has failed when building commit 23f9f6f.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/424/builds/4951) and take a look at the build logs.
  4. Check if the failure is related to this commit (23f9f6f) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/424/builds/4951

Failed tests:

  • test_subprocess

Failed subtests:

  • test_leak_fast_process_del_killed - test.test_subprocess.POSIXProcessTestCase.test_leak_fast_process_del_killed

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/var/lib/buildbot/workers/3.x.gps-raspbian.nondebug/build/Lib/test/test_subprocess.py", line 3128, in test_leak_fast_process_del_killed
    self.assertRaises(OSError, os.waitpid, pid, 0)
AssertionError: OSError not raised by waitpid
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Sep 18, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x RHEL7 LTO + PGO 3.x has failed when building commit 23f9f6f.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/244/builds/5460) and take a look at the build logs.
  4. Check if the failure is related to this commit (23f9f6f) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/244/builds/5460

Failed tests:

  • test.test_asyncio.test_subprocess

Failed subtests:

  • test_subprocess_consistent_callbacks - test.test_asyncio.test_subprocess.SubprocessThreadedWatcherTests.test_subprocess_consistent_callbacks

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.lto-pgo/build/Lib/test/test_asyncio/test_subprocess.py", line 788, in test_subprocess_consistent_callbacks
    self.loop.run_until_complete(main())
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.lto-pgo/build/Lib/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.lto-pgo/build/Lib/test/test_asyncio/test_subprocess.py", line 780, in main
    self.assertEqual(events, [
AssertionError: Lists differ: [('pi[29 chars]t'), 'pipe_connection_lost', ('pipe_data_recei[57 chars]ted'] != [('pi[29 chars]t'), ('pipe_data_received', 2, b'stderr'), 'pi[57 chars]ted']
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hauntsaninja
hauntsaninja deleted the unparse-quote-main branch September 18, 2023 17:44
csm10495 pushed a commit to csm10495/cpython that referenced this pull request Sep 28, 2023
@hauntsaninja @csm10495
pythongh-108843: fix ast.unparse for f-string with many quotes (pytho…
0fe458e
…n#108981)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sunmy2019 sunmy2019 sunmy2019 approved these changes
@isidentical isidentical Awaiting requested review from isidentical isidentical is a code owner
@Yhg1s Yhg1s Awaiting requested review from Yhg1s
@pablogsal pablogsal Awaiting requested review from pablogsal

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@hauntsaninja @miss-islington @pablogsal @bedevere-bot @sunmy2019
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.