Skip to content

Conversation

hauntsaninja
Copy link
Contributor

@hauntsaninja hauntsaninja commented Sep 6, 2023

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.

@sunmy2019 sunmy2019 requested review from Yhg1s and pablogsal September 6, 2023 06:20
@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
Copy link
Contributor

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 18, 2023
…nGH-108981) (cherry picked from commit 23f9f6f) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
@pablogsal
Copy link
Member

Thanks a lot @hauntsaninja !

@bedevere-app
Copy link

bedevere-app bot commented Sep 18, 2023

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

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

⚠️⚠️⚠️ 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 "] 
Yhg1s pushed a commit that referenced this pull request Sep 18, 2023
…08981) (#109541) gh-108843: fix ast.unparse for f-string with many quotes (GH-108981) (cherry picked from commit 23f9f6f) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
@bedevere-bot
Copy link

⚠️⚠️⚠️ 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 
@bedevere-bot
Copy link

⚠️⚠️⚠️ 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'] 
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants