Skip to content

Commit

Permalink
Save faulthandler files under xdg_data_home/spyder on Linux
Browse files Browse the repository at this point in the history
Also, avoid any error when trying to remove them and cancel some linting
warnings.
  • Loading branch information
ccordoba12 committed Feb 25, 2024
1 parent d0b6a86 commit 26243ef
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions spyder_kernels/console/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ def enable_faulthandler(self):
# Do not use /tmp for temporary files
try:
from xdg.BaseDirectory import xdg_data_home
fault_dir = xdg_data_home
fault_dir = os.path.join(xdg_data_home, "spyder")
os.makedirs(fault_dir, exist_ok=True)
except Exception:
fault_dir = None

self.faulthandler_handle = tempfile.NamedTemporaryFile(
'wt', suffix='.fault', dir=fault_dir)
'wt', suffix='.fault', dir=fault_dir
)

main_id = threading.main_thread().ident
system_ids = [
thread.ident for thread in threading.enumerate()
Expand Down Expand Up @@ -172,9 +174,7 @@ def get_fault_text(self, fault_filename, main_id, ignore_ids):
# Remove file
try:
os.remove(fault_filename)
except FileNotFoundError:
pass
except PermissionError:
except Exception:
pass

# Process file
Expand Down Expand Up @@ -721,13 +721,13 @@ def set_special_kernel(self, special):
return

if special == "pylab":
import matplotlib
import matplotlib # noqa
exec("from pylab import *", self.shell.user_ns)
self.shell.special = special
return

if special == "sympy":
import sympy
import sympy # noqa
sympy_init = "\n".join([
"from sympy import *",
"x, y, z, t = symbols('x y z t')",
Expand All @@ -740,7 +740,7 @@ def set_special_kernel(self, special):
return

if special == "cython":
import cython
import cython # noqa

# Import pyximport to enable Cython files support for
# import statement
Expand Down

0 comments on commit 26243ef

Please sign in to comment.