Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPython console run code lines not being saved in preferences #3354

Closed
dstrozzi opened this issue Aug 15, 2016 · 4 comments
Closed

IPython console run code lines not being saved in preferences #3354

dstrozzi opened this issue Aug 15, 2016 · 4 comments

Comments

@dstrozzi
Copy link

Description of your problem

I am running Spyder 2.3.9 on Windows 7, using the Anaconda Python 3.5.2 distribution. Anaconda is up to date on my system. I can't get Spyder to remember "run code" preference for ipython console. In particular, using the Spyder gui, I click on Tools -> Preferences -> IPython console -> Startup tab. I enter something in the Run code lines: dialog, like print('hello world'). Click Apply, OK. If I go back to preferences, this box is empty. If I start an ipython console, the print statement isn't executed.

The specific problem that got me on this is setting how floating-point numbers are formatted. By default, ipython in Spyder doesn't use scientific notation until many decimal places. I wanted to add the ipython magic command '%precision %.4g'. Can't add it to run code lines dialog. Added to my ipython_config.py, works when I start a free-standing ipython from a prompt. Not in Spyder.

What steps will reproduce the problem?

  1. Tools -> Preferences -> IPython console -> Startup ->
  2. Enter text in Run code Lines, e.g. print('foo')
  3. Click OK
  4. Go back to that dialog box, Lines field is empty

Versions and main components

  • Spyder Version: 2.3.9
  • Python Version: 2.5.2
  • Operating system: Windows 7.

Dependencies

Please go to the menu entry Help > Optional Dependencies (or
Help > Dependencies), press the button Copy to clipboard
and paste the contents below:

IPython >=1.0 : 5.0.0 (OK)
jedi >=0.8.1;<0.9.0: 0.9.0 (NOK)
matplotlib >=1.0 : 1.5.1 (OK)
pandas >=0.13.1 : 0.18.1 (OK)
pep8 >=0.6 : 1.7.0 (OK)
pyflakes >=0.6.0 : 1.2.3 (OK)
pygments >=1.6 : 2.1.3 (OK)
pylint >=0.25 : None (NOK)
qtconsole >=4.0 : 4.2.1 (OK)
rope >=0.9.2 : 0.9.4-1 (OK)
sphinx >=0.6.6 : 1.3.1 (OK)
sympy >=0.7.3 : 1.0 (OK)
zmq >=2.1.11 : 15.4.0 (OK)

@jitseniesen
Copy link
Member

Thank you for your report. This issue is still present in the latest version. The problem is that when loading the config file, the string is eval()ed. I'm looking into it.

@jitseniesen jitseniesen self-assigned this Aug 17, 2016
@ccordoba12
Copy link
Member

@jitseniesen, the problem is settings location changed in the transition from IPython to Jupyter.

I think I already fixed this error in PR #2878 ;-)

jitseniesen added a commit to jitseniesen/spyder that referenced this issue Aug 17, 2016
Using eval() has unintended side-effects. Instead, do nothing if we expect a string,
and use ast.literal_eval() for other types (list, tuple, etc.)

Fixes spyder-ide#3354.
@jitseniesen
Copy link
Member

It looks like there several problems. I don't think your PR fixes the issue described here; I tried it the steps under "What steps will reproduce the problem?" with your branch and the issue persists. It has to do with the config system and not with the IPython plugin.

@ccordoba12
Copy link
Member

Ok, I see. Then please go ahead and fix it :-)

jitseniesen added a commit to jitseniesen/spyder that referenced this issue Aug 22, 2016
Using eval() has unintended side-effects. Instead, do nothing if we expect a string,
and use ast.literal_eval() for other types (list, tuple, etc.)

Fixes spyder-ide#3354.
@ccordoba12 ccordoba12 modified the milestones: v3.0beta6, v3.0beta7 Aug 27, 2016
jitseniesen added a commit to jitseniesen/spyder that referenced this issue Aug 29, 2016
Using eval() has unintended side-effects. Instead, do nothing if we expect a string,
and use ast.literal_eval() for other types (list, tuple, etc.)

Fixes spyder-ide#3354.
jitseniesen added a commit to jitseniesen/spyder that referenced this issue Sep 1, 2016
Using eval() has unintended side-effects. Instead, do nothing if we expect a string,
and use ast.literal_eval() for other types (list, tuple, etc.)

Fixes spyder-ide#3354.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants