This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: test_genericalias fails if ctypes is missing
Type: Stage: resolved
Components: Tests Versions: Python 3.10
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Jeffrey.Kintscher, vstinner
Priority: normal Keywords: patch

Created on 2020-08-04 15:05 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 21766 merged vstinner, 2020-08-07 15:29
Messages (2)
msg374820 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-08-04 15:05

0:05:47 load avg: 5.95 [311/423/2] test_genericalias failed -- running: test_multiprocessing_spawn (1 min 59 sec)
test test_genericalias crashed -- Traceback (most recent call last):                                                                                                                         
  File "/home/vstinner/python/master/Lib/test/libregrtest/", line 272, in _runtest_inner        
    refleak = _runtest_inner2(ns, test_name)                                                                                                                                                 
  File "/home/vstinner/python/master/Lib/test/libregrtest/", line 223, in _runtest_inner2         
    the_module = importlib.import_module(abstest)                                                                                                                                            
  File "/home/vstinner/python/master/Lib/importlib/", line 126, in import_module                                                                                                  
    return _bootstrap._gcd_import(name[level:], package, level)                                                                                                                              
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import                                                                                                                            
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load                                                                                                                         
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked                                                                                                                 
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked                                                                                                                          
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module                                                                                                                    
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed                                                                                                               
  File "/home/vstinner/python/master/Lib/test/", line 16, in <module>                                                                                                    
    from ctypes import Array, LibraryLoader
  File "/home/vstinner/python/master/Lib/ctypes/", line 8, in <module>
    from _ctypes import Union, Structure, Array 
ModuleNotFoundError: No module named '_ctypes'

The minimum fix is to skip test_genericalias is ctypes is missing. For example, use "ctypes = support.import_helper.import_module('ctypes')" to import ctypes.

See also bpo-41476: test_zoneinfo fails if the _lzma module is missing.
msg375007 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-08-07 15:57
New changeset f44693eaed3b9d91a6e415d48224fd4750b59366 by Victor Stinner in branch 'master':
bpo-41477: Make ctypes optional in test_genericalias (GH-21766)
Date User Action Args
2022-04-11 14:59:34adminsetgithub: 85649
2020-09-07 15:31:11vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-08-07 15:57:01vstinnersetmessages: + msg375007
2020-08-07 15:29:26vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request20910
2020-08-05 23:23:18Jeffrey.Kintschersetnosy: + Jeffrey.Kintscher
2020-08-04 15:05:40vstinnercreate