summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2018-05-02 11:56:49 -0400
committerEric Lin <anselor@gmail.com>2018-05-02 11:56:49 -0400
commit97668f9464a6a4cb89e82ccf1c1e8b78146a70fd (patch)
tree737fbb94f73eda5f9b180382b0bdaa64a868084b /cmd2/cmd2.py
parent2528fb5217063a5a98f7ea2b880bfc75e7f2428c (diff)
downloadcmd2-git-97668f9464a6a4cb89e82ccf1c1e8b78146a70fd.tar.gz
Restored legacy cmd/self access when locals_in_py is True. Changed default to False
Diffstat (limited to 'cmd2/cmd2.py')
-rwxr-xr-xcmd2/cmd2.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 3a07f8ce..eb80351b 100755
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -699,7 +699,7 @@ class Cmd(cmd.Cmd):
if _which(editor):
break
feedback_to_output = False # Do not include nonessentials in >, | output by default (things like timing)
- locals_in_py = True
+ locals_in_py = False
quiet = False # Do not suppress nonessential output
timing = False # Prints elapsed time for each command
@@ -2907,7 +2907,11 @@ Usage: Usage: unalias [-a] name [name ...]
self.pystate['run'] = run
self.pystate[self.pyscript_name] = bridge
- localvars = (self.locals_in_py and self.pystate) or {}
+ if self.locals_in_py:
+ self.pystate['self'] = self
+ self.pystate['cmd'] = onecmd_plus_hooks
+
+ localvars = self.pystate
interp = InteractiveConsole(locals=localvars)
interp.runcode('import sys, os;sys.path.insert(0, os.getcwd())')