original_docstring: Executes code in temporary working directory.
docstring: Executes code in temporary working directory.
docstring_tokens: Executes code in temporary working directory .
code: def run_in_tmp_dir(code):
      """Executes code in temporary working directory."""
      with tempfile.TemporaryDirectory() as tmp_dir:
          cwd = os.getcwd()
          os.chdir(tmp_dir)
  
          # Use runpy instead of exec here because a) it doesn't interfere with
          # globals and b) it gives better error messages.
          with open("code.py", "w") as f:
              f.write(code)
          try:
              runpy.run_path("code.py")
          finally:
              os.chdir(cwd)
code_tokens: def run_in_tmp_dir ( code ) : with tempfile . TemporaryDirectory ( ) as tmp_dir : cwd = os . getcwd ( ) os . chdir ( tmp_dir ) with open ( "code.py" , "w" ) as f : f . write ( code ) try : runpy . run_path ( "code.py" ) finally : os . chdir ( cwd )
short_docstring: Executes code in temporary working directory.
short_docstring_tokens: Executes code in temporary working directory .
comment: """Executes code in temporary working directory."""$SEP$# Use runpy instead of exec here because a) it doesn't interfere with$SEP$# globals and b) it gives better error messages.