Skip to content

Commit c88df51

Browse files
committed
Add one more test case
1 parent 77ab121 commit c88df51

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

Lib/test/datetimetester.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7531,6 +7531,31 @@ def test_gh_151039(self):
75317531
"""
75327532
rc, out, err = script_helper.assert_python_ok("-c", script)
75337533
self.assertEqual(rc, 0)
7534+
self.assertEqual(out, b'')
7535+
self.assertEqual(err, b'')
7536+
7537+
@support.cpython_only
7538+
def test_static_type_at_shutdown(self):
7539+
# gh-132413
7540+
script = textwrap.dedent("""
7541+
import _datetime
7542+
timedelta = _datetime.timedelta
7543+
7544+
def gen():
7545+
try:
7546+
yield
7547+
finally:
7548+
# sys.modules is empty
7549+
_datetime.timedelta(days=1)
7550+
timedelta(days=1)
7551+
7552+
it = gen()
7553+
next(it)
7554+
""")
7555+
rc, out, err = script_helper.assert_python_ok("-c", script)
7556+
self.assertEqual(rc, 0)
7557+
self.assertEqual(out, b'')
7558+
self.assertEqual(err, b'')
75347559

75357560

75367561
def load_tests(loader, standard_tests, pattern):

Modules/_datetimemodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,6 +3032,7 @@ delta_total_seconds(PyObject *op, PyObject *Py_UNUSED(dummy))
30323032
datetime_state *st = GET_CURRENT_STATE(current_mod);
30333033
if (st == NULL) {
30343034
assert(current_mod == NULL);
3035+
Py_DECREF(total_microseconds);
30353036
return NULL;
30363037
}
30373038

0 commit comments

Comments
 (0)