Skip to content

Commit

Permalink
Merge pull request #500 from ccordoba12/restore-tmpdir
Browse files Browse the repository at this point in the history
PR: Restore `TMPDIR` env var if it was available on the Spyder side
  • Loading branch information
ccordoba12 authored Aug 29, 2024
2 parents 66d58eb + b6ffbb4 commit 80a08c8
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions spyder_kernels/customize/spydercustomize.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,25 @@ def _patched_get_terminal_size(fd=None):
# =============================================================================
# Remove TMPDIR env var in case it was set by Spyder
# =============================================================================
# See spyder-ide/spyder#22382 for the details.
try:
os.environ.pop("TMPDIR")
except KeyError:
pass

# See spyder-ide/spyder#22382 and spyder-ide/spyder#22394 for the details.
def restore_tmpdir():
# This check is necessary for external/remote kernels because SPY_TMPDIR
# is not available for them.
if os.environ.get("SPY_TMPDIR") is not None:
spy_tmpdir = os.environ.get("SPY_TMPDIR")

if spy_tmpdir != "":
# This means TMPDIR was available in the system when the kernel
# started, so we need to restore it.
os.environ.update({"TMPDIR": spy_tmpdir})
else:
# Otherwise, we simply need to remove it
try:
os.environ.pop("TMPDIR")
except KeyError:
pass

restore_tmpdir()

# =============================================================================
# PYTHONPATH and sys.path Adjustments
Expand Down

0 comments on commit 80a08c8

Please sign in to comment.