Skip to content

Commit 5263aa8

Browse files
authored
Merge pull request #994 from mathics/set-direcory-fixes
Set directory fixes
2 parents d1d3b43 + 21c7a5d commit 5263aa8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Diff for: mathics/builtin/files.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -2186,7 +2186,7 @@ class Put(BinaryOperator):
21862186
## = Put[815915283247897734345611269596115894272000000000, fortyfactorial]
21872187
21882188
S> filename = $TemporaryDirectory <> "/fortyfactorial";
2189-
S> Put[40!, filename]
2189+
S> Put[40!, filename]
21902190
S> FilePrint[filename]
21912191
| 815915283247897734345611269596115894272000000000
21922192
S> Get[filename]
@@ -4298,13 +4298,16 @@ def apply(self, path, evaluation):
42984298
return
42994299

43004300
py_path = path.__str__()[1:-1]
4301-
py_path = path_search(py_path)
43024301

4303-
if py_path is None:
4302+
if py_path is None or not os.path.isdir(py_path):
43044303
evaluation.message('SetDirectory', 'cdir', path)
43054304
return Symbol('$Failed')
43064305

4307-
os.chdir(py_path)
4306+
try:
4307+
os.chdir(py_path)
4308+
except:
4309+
return Symbol('$Failed')
4310+
43084311
DIRECTORY_STACK.append(os.getcwd())
43094312
return String(os.getcwd())
43104313

Diff for: mathics/builtin/system.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ class UserName(Predefined):
355355
<dl>
356356
<dt>$UserName
357357
<dd>returns a string describing the type of computer system on which
358-
\Mathics is being run.
358+
Mathics is being run.
359359
</dl>
360360
361361
X> $UserName

0 commit comments

Comments
 (0)