mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
Add a native _zoneinfo module (#8915)
* Add a native _zoneinfo module ZoneInfo reads TZif tuples from zoneinfo._common.load_data. The stdlib module implements utcoffset, dst, tzname, fromutc, and the zone cache. whats_left compares that class. Cache tests no longer expect failure. Assisted-by: Grok:grok-4.7 * Fix ZoneInfo layout and keep its cache on the module utcoffset, dst, and tzname take the object. Zone data is boxed so the payload lines up with tzinfo on 32-bit. The strong, weak, and timedelta caches live on each interpreter's _zoneinfo module. Assisted-by: Grok:grok-4.7
This commit is contained in:
1 parent
ab3d759e74
commit
cb0f3b012b
6 files changed
+1479
-23
No files matched your search
@@ -414,20 +414,6 @@ def _pure_decimal_baseline(wrapper):
|
||||
return result
|
||||
|
||||
|
||||
def _use_pure_zoneinfo(dir_result):
|
||||
"""Replace the accelerated ZoneInfo with the pure-Python class."""
|
||||
import zoneinfo._zoneinfo as pure_zoneinfo
|
||||
|
||||
cls = pure_zoneinfo.ZoneInfo
|
||||
name = cls.__name__
|
||||
for key in list(dir_result):
|
||||
if key == name or key.startswith(f"{name}."):
|
||||
del dir_result[key]
|
||||
dir_result[name] = extra_info(cls)
|
||||
for attr, info in own_attrs(cls):
|
||||
dir_result[f"{name}.{attr}"] = info
|
||||
|
||||
|
||||
def gen_modules():
|
||||
# check name because modules listed have side effects on import,
|
||||
# e.g. printing something or opening a webpage
|
||||
@@ -465,8 +451,6 @@ def gen_modules():
|
||||
):
|
||||
for attr, info in own_attrs(item):
|
||||
dir_result[f"{item_name}.{attr}"] = info
|
||||
if mod_name == "zoneinfo":
|
||||
_use_pure_zoneinfo(dir_result)
|
||||
modules[mod_name] = dir_result
|
||||
return modules
|
||||
|
||||
|
||||
Reference in new issue
Block a user