Skip to content

Commit 1c6cd5d

Browse files
committed
src/sage/repl/load.py: replace tmp_dir()
Standard tempfile.TemporaryDirectory() replacement. Issue: #36322
1 parent 4d3e807 commit 1c6cd5d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/sage/repl/load.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,17 @@ def load(filename, globals, attach=False):
177177
current working directory, i.e., ``'.'``. But you can modify the
178178
path with :func:`load_attach_path`::
179179
180+
sage: import tempfile
180181
sage: sage.repl.attach.reset(); reset_load_attach_path()
181182
sage: load_attach_path()
182183
['.']
183-
sage: t_dir = tmp_dir()
184-
sage: fname = 'test.py'
185-
sage: fullpath = os.path.join(t_dir, fname)
186-
sage: with open(fullpath, 'w') as f:
187-
....: _ = f.write("print(37 * 3)")
188-
sage: load_attach_path(t_dir, replace=True)
189-
sage: attach(fname)
184+
sage: with tempfile.TemporaryDirectory() as t_dir:
185+
....: fname = 'test.py'
186+
....: fullpath = os.path.join(t_dir, fname)
187+
....: with open(fullpath, 'w') as f:
188+
....: _ = f.write("print(37 * 3)")
189+
....: load_attach_path(t_dir, replace=True)
190+
....: attach(fname)
190191
111
191192
sage: sage.repl.attach.reset(); reset_load_attach_path() # clean up
192193

0 commit comments

Comments
 (0)