File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2863,3 +2863,18 @@ def control_characters_c0() -> list[str]:
28632863 C0 control characters defined as the byte range 0x00-0x1F, and 0x7F.
28642864 """
28652865 return [chr (c ) for c in range (0x00 , 0x20 )] + ["\x7F " ]
2866+
2867+
2868+ STATUS_DLL_INIT_FAILED = 0xC0000142
2869+ def skip_on_low_desktop_heap_memory_subprocess (returncode ):
2870+ if sys .platform not in ('win32' , 'cygwin' ):
2871+ return
2872+ # On Windows, STATUS_DLL_INIT_FAILED is a generic error code that could
2873+ # come from any of the DLLs being loaded when a new Python process is
2874+ # created. In practice, it's likely a memory allocation failure in the
2875+ # desktop heap memory which caused the DLL init failure, especially on
2876+ # process created with CREATE_NEW_CONSOLE creation flag. See the article:
2877+ # https://learn.microsoft.com/en-us/troubleshoot/windows-server/performance/desktop-heap-limitation-out-of-memory
2878+ if returncode == STATUS_DLL_INIT_FAILED :
2879+ raise unittest .SkipTest ('gh-150436: DLL init failed, likely because '
2880+ 'of low desktop heap memory' )
Original file line number Diff line number Diff line change 44import unittest
55from textwrap import dedent
66
7+ from test import support
78from test .support import os_helper , requires_resource
89from test .support .os_helper import TESTFN , TESTFN_ASCII
910
@@ -67,8 +68,12 @@ def run_in_separated_process(self, code):
6768 # Run test in a separated process to avoid stdin conflicts.
6869 # See: gh-110147
6970 cmd = [sys .executable , '-c' , code ]
70- subprocess .run (cmd , check = True , capture_output = True ,
71- creationflags = subprocess .CREATE_NEW_CONSOLE )
71+ try :
72+ subprocess .run (cmd , check = True , capture_output = True ,
73+ creationflags = subprocess .CREATE_NEW_CONSOLE )
74+ except subprocess .CalledProcessError as exc :
75+ support .skip_on_low_desktop_heap_memory_subprocess (exc .returncode )
76+ raise
7277
7378 def test_kbhit (self ):
7479 code = dedent ('''
Original file line number Diff line number Diff line change @@ -3761,13 +3761,17 @@ def test_startupinfo_copy(self):
37613761 self .assertEqual (startupinfo .wShowWindow , subprocess .SW_HIDE )
37623762 self .assertEqual (startupinfo .lpAttributeList , {"handle_list" : []})
37633763
3764+ # CREATE_NEW_CONSOLE creates a "popup" window.
3765+ @support .requires_resource ('gui' )
37643766 def test_creationflags (self ):
37653767 # creationflags argument
37663768 CREATE_NEW_CONSOLE = 16
37673769 sys .stderr .write (" a DOS box should flash briefly ...\n " )
3768- subprocess .call (sys .executable +
3769- ' -c "import time; time.sleep(0.25)"' ,
3770- creationflags = CREATE_NEW_CONSOLE )
3770+ rc = subprocess .call (sys .executable +
3771+ ' -c "import time; time.sleep(0.25)"' ,
3772+ creationflags = CREATE_NEW_CONSOLE )
3773+ support .skip_on_low_desktop_heap_memory_subprocess (rc )
3774+ self .assertEqual (rc , 0 )
37713775
37723776 def test_invalid_args (self ):
37733777 # invalid arguments should raise ValueError
You can’t perform that action at this time.
0 commit comments