GeezerVison is showing github.com — gh-116437: Use new C API PyDict_Pop() to simplify the code by serhiy-storchaka · Pull Request #116438 · python/cpython
Conversation
serhiy-storchaka
commented
Mar 6, 2024
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
It also fixes leaks in Python/Python-ast.c.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe replace == -1 with < 0 to check for failure.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
erlend-aasland reacted with thumbs up emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thank you for your review Victor.
|
vstinner reacted with heart emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️
Hi! The buildbot AMD64 Ubuntu NoGIL Refleaks 3.x has failed when building commit 72d3cc9.
What do you need to do:
- Don't panic.
- Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
- Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1226/builds/1401) and take a look at the build logs.
- Check if the failure is related to this commit (72d3cc9) or if it is a false positive.
- 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/1226/builds/1401
Failed tests:
Failed subtests:
- test_flock - main.FNTLEINTRTest.test_flock
- test_all - test.test_eintr.EINTRTests.test_all
- test_rollover_at_midnight - test.test_logging.TimedRotatingFileHandlerTest.test_rollover_at_midnight
- test_map_timeout - test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_map_timeout
- test_lockf - main.FNTLEINTRTest.test_lockf
Test leaking resources:
- test_queue: memory blocks
Summary of the results of the build (if available):
==
Click to see traceback logs
Traceback (most recent call last):
File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/test/test_eintr.py", line 17, in test_all
script_helper.run_test_script(script)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/test/support/script_helper.py", line 316, in run_test_script
raise AssertionError(f"{name} failed")
AssertionError: script _test_eintr.py failed
Traceback (most recent call last):
File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/test/test_logging.py", line 6111, in test_rollover_at_midnight
self.assertIn(f'testing2 {i}', line)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'testing2 0' not found in '2024-03-07 12:13:26,043 testing1 0\n'
Traceback (most recent call last):
File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/threading.py", line 1080, in _bootstrap_inner
self.run()
~~~~~~~~^^
File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/threading.py", line 1017, in run
self._target(*self._args, **self._kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/queue.py", line 85, in task_done
raise ValueError('task_done() called too many times')
ValueError: task_done() called too many times
k
Traceback (most recent call last):
File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/test/test_concurrent_futures/executor.py", line 71, in test_map_timeout
self.assertEqual([None, None], results)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Lists differ: [None, None] != []
Traceback (most recent call last):
File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/test/_test_eintr.py", line 535, in test_flock
self._lock(fcntl.flock, "flock")
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/test/_test_eintr.py", line 517, in _lock
raise Exception("failed to sync child in %.1f sec" % dt)
Exception: failed to sync child in 300.5 sec
Traceback (most recent call last):
File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/test/_test_eintr.py", line 532, in test_lockf
self._lock(fcntl.lockf, "lockf")
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/test/_test_eintr.py", line 517, in _lock
raise Exception("failed to sync child in %.1f sec" % dt)
Exception: failed to sync child in 300.6 sec
Traceback (most recent call last):
File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/test/test_logging.py", line 6111, in test_rollover_at_midnight
self.assertIn(f'testing2 {i}', line)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'testing2 0' not found in '2024-03-07 11:49:20,006 testing1 0\n'
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the post-merge review. I was curious about what changed and happened to notice a few things.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
-17559
to
+17563
|
|
if (PyDict_DelItemString(dct, "pwritev") == -1) {
|
|
|
PyErr_Clear();
|
|
|
if (PyDict_PopString(dct, "pwritev", NULL) < 0) {
|
|
|
return -1;
|
|
|
}
|
|
|
if (PyDict_DelItemString(dct, "preadv") == -1) {
|
|
|
PyErr_Clear();
|
|
|
if (PyDict_PopString(dct, "preadv", NULL) < 0) {
|
|
|
return -1;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is slightly different behavior, isn't it? Before, we tried removing each item and ignored all errors. Now we fail at the first error. Is that okay? (Maybe @ronaldoussoren has some thoughts on this?) Was this intentional?
(The same applies to the changes in Modules/timemodule.c.)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not ignoring errors is always a good thing.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+1081
to
-1093
|
|
int rc = PyDict_Pop(remaining_dict, name, &value);
|
|
|
Py_DECREF(name);
|
|
|
if (rc < 0) {
|
|
|
goto cleanup;
|
|
|
}
|
|
|
if (!value) {
|
|
|
if (PyErr_Occurred()) {
|
|
|
goto cleanup;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
if (PyList_Append(positional_args, value) < 0) {
|
|
|
rc = PyList_Append(positional_args, value);
|
|
|
Py_DECREF(value);
|
|
|
if (rc < 0) {
|
|
|
goto cleanup;
|
|
|
}
|
|
|
if (PyDict_DelItem(remaining_dict, name) < 0) {
|
|
|
goto cleanup;
|
|
|
}
|
|
|
Py_DECREF(name);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch about fixing the decrefs.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
vstinner reacted with thumbs up emoji
Comment on lines
475
to
480
|
|
if (set_file_name) {
|
|
|
if (PyDict_DelItemString(dict, "__file__")) {
|
|
|
PyErr_Clear();
|
|
|
if (PyDict_PopString(dict, "__file__", NULL) < 0) {
|
|
|
PyErr_Print();
|
|
|
}
|
|
|
if (PyDict_DelItemString(dict, "__cached__")) {
|
|
|
PyErr_Clear();
|
|
|
if (PyDict_PopString(dict, "__cached__", NULL) < 0) {
|
|
|
PyErr_Print();
|
|
|
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Using PyErr_Print() here makes sense.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
vstinner reacted with thumbs up emoji
Comment on lines
2045
to
+2057
|
|
swap_current_task(asyncio_state *state, PyObject *loop, PyObject *task)
|
|
|
{
|
|
|
PyObject *prev_task;
|
|
|
|
|
|
if (task == Py_None) {
|
|
|
if (PyDict_Pop(state->current_tasks, loop, &prev_task) < 0) {
|
|
|
return NULL;
|
|
|
}
|
|
|
if (prev_task == NULL) {
|
|
|
Py_RETURN_NONE;
|
|
|
}
|
|
|
return prev_task;
|
|
|
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me a minute to make sense of your changes in this file, but now I get it. 👍
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. I blocked here for 5 minutes :-D
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.
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.
|