@@ -290,13 +290,20 @@ def _check_run_interactive(self, run, encode_filename, use_loop):
290290
291291 def check_run_interactive (self , run , encode_filename , use_loop = False ):
292292 # Redirect stderr to a temporary file to hide '>>> ' from the REPL
293- stderr_copy = os .dup (STDERR_FD )
294- with tempfile .TemporaryFile () as tmp :
295- try :
296- os .dup2 (tmp .fileno (), STDERR_FD )
297- self ._check_run_interactive (run , encode_filename , use_loop )
298- finally :
299- os .dup2 (stderr_copy , STDERR_FD )
293+ try :
294+ stderr_copy = os .dup (STDERR_FD )
295+ except OSError :
296+ # On WASI, dup(STDERR_FD) fails with "OSError: [Errno 58] Not
297+ # supported". In this case, run the test without redirecting
298+ # stderr to a temporary file.
299+ self ._check_run_interactive (run , encode_filename , use_loop )
300+ else :
301+ with tempfile .TemporaryFile () as tmp :
302+ try :
303+ os .dup2 (tmp .fileno (), STDERR_FD )
304+ self ._check_run_interactive (run , encode_filename , use_loop )
305+ finally :
306+ os .dup2 (stderr_copy , STDERR_FD )
300307
301308 def test_run_interactiveone (self ):
302309 # Test PyRun_InteractiveOne()
0 commit comments