Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-132413: Fix crash in _datetime when used at shutdown#132599

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
neonene wants to merge41 commits intopython:main
base:main
Choose a base branch
Loading
fromneonene:fix-132413
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
41 commits
Select commitHold shift + click to select a range
a2d90ae
Update datetimetester.py
neoneneApr 16, 2025
37d317f
Make interp-dict have a strong ref to the module
neoneneApr 16, 2025
44d09c9
Fix exc leak
neoneneApr 16, 2025
19326d4
📜🤖 Added by blurb_it.
blurb-it[bot]Apr 16, 2025
c74251d
Merge branch 'main' into fix-132413
neoneneApr 16, 2025
f805ec7
Add assertion in test
neoneneApr 17, 2025
1539cc6
More assertion
neoneneApr 17, 2025
e6aa018
Allow only module's exec() to create interp-dict
neoneneApr 17, 2025
5141a76
Safer ref cycle between mod and interp-dict
neoneneApr 17, 2025
76cc153
Respect interp-dict held in module state
neoneneApr 17, 2025
e5bb7c8
Update _datetimemodule.c
neoneneApr 20, 2025
2645282
Merge branch 'main' into fix-132413
neoneneApr 20, 2025
87aa7a2
Update datetimetester.py
neoneneApr 20, 2025
b425bc8
Reword
neoneneApr 21, 2025
19de232
typo
neoneneApr 21, 2025
f7b78d9
Reword
neoneneApr 22, 2025
05811bb
Cleanup
neoneneApr 22, 2025
1416c6f
Merge branch 'main' into fix-132413
neoneneApr 22, 2025
351ac36
assert(!_Py_IsInterpreterFinalizing())
neoneneApr 24, 2025
0e4a263
Add tests
neoneneApr 25, 2025
fa0cc40
Update tests
neoneneApr 26, 2025
0377764
Take account of interp restart
neoneneApr 26, 2025
9af13a6
Add subinterp tests
neoneneApr 27, 2025
124d650
Fix tests for free-threaded builds
neoneneApr 27, 2025
c490586
Nit
neoneneApr 27, 2025
29c45a3
Merge branch 'main' into fix-132413
neoneneApr 27, 2025
db47683
Make tests generic
neoneneApr 27, 2025
ddd1635
Fix warnings
neoneneApr 27, 2025
746bf85
Update tests
neoneneApr 30, 2025
1cdaf5a
Merge branch 'main' into fix-132413
neoneneApr 30, 2025
a8f76fa
Revert to original (main)
neoneneMay 7, 2025
c7fc55e
Convert IsoCalendarDate to static type (3.12)
neoneneMay 7, 2025
b3d8a8e
Merge branch 'main' into fix-132413
neoneneMay 7, 2025
539cfed
Fix warning
neoneneMay 7, 2025
f2373f4
Merge branch 'main' into fix-132413
neoneneMay 8, 2025
d9f8544
Fix refleaks
neoneneMay 8, 2025
07ca91f
Ditto
neoneneMay 8, 2025
13b065f
Move up a function
neoneneMay 9, 2025
0052451
Smaller patch for tests
neoneneMay 13, 2025
fb29db1
Merge branch 'main' into fix-132413
neoneneMay 13, 2025
d2e2a11
Add a non-issue test case (closure)
neoneneMay 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Add subinterp tests
  • Loading branch information
@neonene
neonene committedApr 27, 2025
commit9af13a6b4e194c75ef6dbd56fd8bcc76458a1cec
54 changes: 54 additions & 0 deletionsLib/test/datetimetester.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7313,6 +7313,60 @@ def gen():
res = script_helper.assert_python_ok('-c', script)
self.assertFalse(res.err)

def test_static_type_at_shutdown3(self):
script = textwrap.dedent(f'''
import textwrap
from test import support

subinterp_script = textwrap.dedent(f"""
from _testcapi import get_delta_type
# Test without calling test_datetime_capi() in subinterp
timedelta = get_delta_type()

def gen():
try:
yield
finally:
timedelta(days=1)

it = gen()
next(it)
""")

import _testcapi
_testcapi.test_datetime_capi()
ret = support.run_in_subinterp(subinterp_script)
assert ret == 0
''')

res = script_helper.assert_python_ok('-c', script)
self.assertIn(b'ImportError: sys.meta_path is None', res.err)

def test_static_type_before_shutdown(self):
script = textwrap.dedent(f'''
import textwrap
from test import support

subinterp_script = textwrap.dedent(f"""
from _testcapi import get_delta_type
# Test without calling test_datetime_capi() in subinterp

import sys
assert '_datetime' not in sys.modules
timedelta = get_delta_type()
timedelta(days=1)
assert '_datetime' in sys.modules
""")

import _testcapi
_testcapi.test_datetime_capi()
ret = support.run_in_subinterp(subinterp_script)
assert ret == 0
''')

res = script_helper.assert_python_ok('-c', script)
self.assertFalse(res.err)

def test_remain_only_one_module(self):
script = textwrap.dedent("""
import sys
Expand Down
3 changes: 1 addition & 2 deletionsModules/_datetimemodule.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -175,8 +175,7 @@ _get_current_state(PyObject **p_mod)
mod = PyImport_ImportModule("_datetime");
if (mod == NULL) {
assert(_Py_IsInterpreterFinalizing(interp));
/* Ask users to take care about the unlikely case
* that happened after restarting the interpreter. */
/* We do not take care of the unlikely case. */
return NULL;
}
}
Expand Down
7 changes: 7 additions & 0 deletionsModules/_testcapi/datetime.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -453,6 +453,12 @@ test_PyDateTime_DELTA_GET(PyObject *self, PyObject *obj)
return Py_BuildValue("(iii)", days, seconds, microseconds);
}

static PyObject *
get_delta_type(PyObject *self, PyObject *args)
{
return PyDateTimeAPI ? Py_NewRef(PyDateTimeAPI->DeltaType) : Py_None;
}

static PyMethodDef test_methods[] = {
{"PyDateTime_DATE_GET", test_PyDateTime_DATE_GET, METH_O},
{"PyDateTime_DELTA_GET", test_PyDateTime_DELTA_GET, METH_O},
Expand All@@ -469,6 +475,7 @@ static PyMethodDef test_methods[] = {
{"get_datetime_fromdateandtimeandfold", get_datetime_fromdateandtimeandfold, METH_VARARGS},
{"get_datetime_fromtimestamp", get_datetime_fromtimestamp, METH_VARARGS},
{"get_delta_fromdsu", get_delta_fromdsu, METH_VARARGS},
{"get_delta_type", get_delta_type, METH_NOARGS},
{"get_time_fromtime", get_time_fromtime, METH_VARARGS},
{"get_time_fromtimeandfold", get_time_fromtimeandfold, METH_VARARGS},
{"get_timezone_utc_capi", get_timezone_utc_capi, METH_VARARGS},
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp