From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 22 Jan 2026 11:15:00 +0000 (+0100) Subject: [3.13] gh-143959: Make _datetime optional for test_sys (GH-144003) (#144144) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=015b90dc0226ac1899d767f8d9f27f6f228cb033;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-143959: Make _datetime optional for test_sys (GH-144003) (#144144) gh-143959: Make _datetime optional for test_sys (GH-144003) (cherry picked from commit c447d1bc146bcf7707a619779bdcc03651adb5e3) Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com> --- diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 7b4901040ba0..786832d3e35b 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1,6 +1,5 @@ import builtins import codecs -import _datetime import gc import io import locale @@ -1740,7 +1739,12 @@ class SizeofTest(unittest.TestCase): x = property(getx, setx, delx, "") check(x, size('5Pi')) # PyCapsule - check(_datetime.datetime_CAPI, size('6P')) + try: + import _datetime + except ModuleNotFoundError: + pass + else: + check(_datetime.datetime_CAPI, size('6P')) # rangeiterator check(iter(range(1)), size('3l')) check(iter(range(2**65)), size('3P'))