- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.3k
gh-137754: Fix import of zoneinfo if _datetime is not available #137845
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            serhiy-storchaka
  merged 5 commits into
  python:main
from
serhiy-storchaka:import-zoneinfo-pydatetime
  
      
      
   
  Aug 23, 2025 
      
    
                
     Merged
            
            gh-137754: Fix import of zoneinfo if _datetime is not available #137845
                    serhiy-storchaka
  merged 5 commits into
  python:main
from
serhiy-storchaka:import-zoneinfo-pydatetime
  
      
      
   
  Aug 23, 2025 
              
            Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    Both modules should use the Python implementation in that case.
33ebff4    to
    312a09c      
    Compare
  
    
              
                    brettcannon
  
              
              approved these changes
              
                  
                    Aug 18, 2025 
                  
              
              
            
            
              
                    AA-Turner
  
              
              approved these changes
              
                  
                    Aug 18, 2025 
                  
              
              
            
            
| Windows is failing as it can't find  Traceback (most recent call last):
  File "D:\a\cpython\cpython\Lib\zoneinfo\_common.py", line 12, in load_tzdata
    path = resources.files(package_name).joinpath(resource_name)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "D:\a\cpython\cpython\Lib\importlib\resources\_common.py", line 46, in wrapper
    return func(anchor)
  File "D:\a\cpython\cpython\Lib\importlib\resources\_common.py", line 56, in files
    return from_package(resolve(anchor))
                        ~~~~~~~^^^^^^^^
  File "D:\a\cpython\cpython\Lib\functools.py", line 982, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "D:\a\cpython\cpython\Lib\importlib\resources\_common.py", line 82, in _
    return importlib.import_module(cand)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "D:\a\cpython\cpython\Lib\importlib\__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1398, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1314, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1398, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1314, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1398, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1335, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tzdata'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<string>", line 6, in <module>
    tzinfo = zoneinfo.ZoneInfo('Europe/Paris')
  File "D:\a\cpython\cpython\Lib\zoneinfo\_zoneinfo.py", line 43, in __new__
    instance = cls._weak_cache.setdefault(key, cls._new_instance(key))
                                               ~~~~~~~~~~~~~~~~~^^^^^
  File "D:\a\cpython\cpython\Lib\zoneinfo\_zoneinfo.py", line 70, in _new_instance
    file_obj = _common.load_tzdata(key)
  File "D:\a\cpython\cpython\Lib\zoneinfo\_common.py", line 29, in load_tzdata
    raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key Europe/Paris' | 
| Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. | 
    
  miss-islington 
      pushed a commit
        to miss-islington/cpython
      that referenced
      this pull request
    
      Aug 23, 2025 
    
    
      
  
    
      
    
  
…pythonGH-137845) Both modules should use the Python implementation in that case. (cherry picked from commit 6620ef0) Co-authored-by: Serhiy Storchaka <[email protected]>
    
  miss-islington 
      pushed a commit
        to miss-islington/cpython
      that referenced
      this pull request
    
      Aug 23, 2025 
    
    
      
  
    
      
    
  
…pythonGH-137845) Both modules should use the Python implementation in that case. (cherry picked from commit 6620ef0) Co-authored-by: Serhiy Storchaka <[email protected]>
| GH-138084 is a backport of this pull request to the 3.14 branch. | 
| GH-138085 is a backport of this pull request to the 3.13 branch. | 
    
  serhiy-storchaka 
      added a commit
      that referenced
      this pull request
    
      Aug 23, 2025 
    
    
      
  
    
      
    
  
GH-137845) (GH-138085) Both modules should use the Python implementation in that case. (cherry picked from commit 6620ef0) Co-authored-by: Serhiy Storchaka <[email protected]>
    
  encukou 
      pushed a commit
      that referenced
      this pull request
    
      Oct 8, 2025 
    
    
      
  
    
      
    
  
GH-137845) (GH-138084) Both modules should use the Python implementation in that case. (cherry picked from commit 6620ef0) Co-authored-by: Serhiy Storchaka <[email protected]>
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Both modules should use the Python implementation in that case.
_pydatetimerejectsZoneInfoas tzinfo yet C datetime accepts #137754