Skip to content

Conversation

@neonene
Copy link
Contributor

@neoneneneonene commented Jun 21, 2024

When reloading _datetime module, the single-phase version did not invoke the PyInit__datetime function, whereas the current multi-phase version updates the static types through the module init. The outdated static type cache in the interpreter state needs to be invalidated at the end of reloading the multi-phase module.

@neonene
Copy link
ContributorAuthor

Copy link
Member

@ericsnowcurrentlyericsnowcurrently left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@Eclips4Eclips4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kumaraditya303kumaraditya303 merged commit a81d434 into python:mainJun 21, 2024
_datetime.time.max > _datetime.time.min
_datetime.datetime.max > _datetime.datetime.min
_datetime.timedelta.max > _datetime.timedelta.min
isinstance(_datetime.timezone.min, _datetime.tzinfo)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have assert?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 assert isinstance(_datetime.timezone.min, _datetime.tzinfo) ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError 
 assert not isinstance(_datetime.timezone.min, _datetime.tzinfo) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError 

Both fail, so this checks if it crashes or not. I agree this is not a good example.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the code looks a bit unusual, it would be worth adding a brief comment explaining that.

(Sorry I didn't notice this during my earlier review. Good catch, @JelleZijlstra.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to have these asserts actually check that the values are of the type they should be? The bug manifested itself as these values appearing to be objects of various random types.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also assert that timezone.__dict__["min"] is timezone.min.

@neonene
Copy link
ContributorAuthor

Thanks. I'll make a backport PR to 3.13 manually with an assertion to the test case.

@bedevere-app
Copy link

GH-120855 is a backport of this pull request to the 3.13 branch.

@neoneneneonene deleted the reload branch June 21, 2024 20:13
kumaraditya303 pushed a commit that referenced this pull request Jul 3, 2024
…H-120829) (#120855) * [3.13] gh-120782: Update internal type cache when reloading datetime When reloading _datetime module, the single-phase version did not invoke the PyInit__datetime function, whereas the current multi-phase version updates the static types through the module init. The outdated static type cache in the interpreter state needs to be invalidated at the end of reloading the multi-phase module.
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot iOS ARM64 Simulator 3.13 has failed when building commit 2c3aa52.

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/1386/builds/305) and take a look at the build logs.
  4. Check if the failure is related to this commit (2c3aa52) 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/1386/builds/305

Failed tests:

  • test_datetime

Failed subtests:

  • test_type_check_in_subinterp - test.datetimetester.CapiTest_Fast.test_type_check_in_subinterp

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last): File �[35m"<string>"�[0m, line �[35m12�[0m, in �[35m<module>�[0m File �[35m"<frozen importlib._bootstrap>"�[0m, line �[35m813�[0m, in �[35mmodule_from_spec�[0m File �[35m"<frozen importlib._bootstrap_external>"�[0m, line �[35m1316�[0m, in �[35mcreate_module�[0m File �[35m"<frozen importlib._bootstrap>"�[0m, line �[35m488�[0m, in �[35m_call_with_frames_removed�[0m �[1;35mImportError�[0m: �[35mdlopen(/Users/buildbot/Library/Developer/XCTestDevices/22CEEEC0-69AF-41A1-B570-E2195120FCE2/data/Containers/Bundle/Application/781AEFA7-0473-4CB0-82EE-01996600BD3C/iOSTestbed.app/python/lib/python3.13/lib-dynload/_testcapi.cpython-313d-iphonesimulator.fwork, 0x0002): tried: '/Users/buildbot/buildarea/3.13.rkm-arm64-ios-simulator.iOS-simulator.arm64/build/build_oot/host/iOSTestbed.arm64-iphonesimulator.1719996652/DerivedData/Build/Products/Debug-iphonesimulator/_testcapi.cpython-313d-iphonesimulator.fwork' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib/_testcapi.cpython-313d-iphonesimulator.fwork' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21F79/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.5.simruntime/Contents/Resources/RuntimeRoot/Users/buildbot/Library/Developer/XCTestDevices/22CEEEC0-69AF-41A1-B570-E2195120FCE2/data/Containers/Bundle/Application/781AEFA7-0473-4CB0-82EE-01996600BD3C/iOSTestbed.app/python/lib/python3.13/lib-dynload/_testcapi.cpython-313d-iphonesimulator.fwork' (no such file), '/Users/buildbot/Library/Developer/XCTestDevices/22CEEEC0-69AF-41A1-B570-E2195120FCE2/data/Containers/Bundle/Application/781AEFA7-0473-4CB0-82EE-01996600BD3C/iOSTestbed.app/python/lib/python3.13/lib-dynload/_testcapi.cpython-313d-iphonesimulator.fwork' (not a mach-o file)�[0m Traceback (most recent call last): File �[35m"<string>"�[0m, line �[35m12�[0m, in �[35m<module>�[0m File �[35m"<frozen importlib._bootstrap>"�[0m, line �[35m813�[0m, in �[35mmodule_from_spec�[0m File �[35m"<frozen importlib._bootstrap_external>"�[0m, line �[35m1316�[0m, in �[35mcreate_module�[0m File �[35m"<frozen importlib._bootstrap>"�[0m, line �[35m488�[0m, in �[35m_call_with_frames_removed�[0m �[1;35mImportError�[0m: �[35mdlopen(/Users/buildbot/Library/Developer/XCTestDevices/22CEEEC0-69AF-41A1-B570-E2195120FCE2/data/Containers/Bundle/Application/781AEFA7-0473-4CB0-82EE-01996600BD3C/iOSTestbed.app/python/lib/python3.13/lib-dynload/_testcapi.cpython-313d-iphonesimulator.fwork, 0x0002): tried: '/Users/buildbot/buildarea/3.13.rkm-arm64-ios-simulator.iOS-simulator.arm64/build/build_oot/host/iOSTestbed.arm64-iphonesimulator.1719996652/DerivedData/Build/Products/Debug-iphonesimulator/_testcapi.cpython-313d-iphonesimulator.fwork' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib/_testcapi.cpython-313d-iphonesimulator.fwork' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21F79/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.5.simruntime/Contents/Resources/RuntimeRoot/Users/buildbot/Library/Developer/XCTestDevices/22CEEEC0-69AF-41A1-B570-E2195120FCE2/data/Containers/Bundle/Application/781AEFA7-0473-4CB0-82EE-01996600BD3C/iOSTestbed.app/python/lib/python3.13/lib-dynload/_testcapi.cpython-313d-iphonesimulator.fwork' (no such file), '/Users/buildbot/Library/Developer/XCTestDevices/22CEEEC0-69AF-41A1-B570-E2195120FCE2/data/Containers/Bundle/Application/781AEFA7-0473-4CB0-82EE-01996600BD3C/iOSTestbed.app/python/lib/python3.13/lib-dynload/_testcapi.cpython-313d-iphonesimulator.fwork' (not a mach-o file)�[0m Traceback (most recent call last): File "/Users/buildbot/Library/Developer/XCTestDevices/22CEEEC0-69AF-41A1-B570-E2195120FCE2/data/Containers/Bundle/Application/781AEFA7-0473-4CB0-82EE-01996600BD3C/iOSTestbed.app/python/lib/python3.13/test/datetimetester.py", line 6828, in test_type_check_in_subinterpself.assertEqual(ret, 0) ~~~~~~~~~~~~~~~~^^^^^^^^AssertionError: -1 != 0

noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@neonene@bedevere-bot@JelleZijlstra@ericsnowcurrently@kumaraditya303@Eclips4