%env magic fails with Python 3.2 #1201

Closed
ColMcp opened this Issue Dec 23, 2011 · 1 comment

Comments

Projects
None yet
3 participants

ColMcp commented Dec 23, 2011

%env magic command fails with Python 3.2 because os.environ does not have an attribute called "data" - see traceback below.
Platform is Python 3.2.2, IPython 0.12, Mac OS X 10.7.2

Traceback
--------------
Python 3.2.2 (v3.2.2:137e45f15c0b, Sep  3 2011, 17:28:59) 
Type "copyright", "credits" or "license" for more information.

IPython 0.12 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: %env

AttributeError                            Traceback (most recent call last)
/Users/colin/Python/readline-6.2.1/<ipython-input-1-d53f11c3c8bf> in <module>()
----> 1 get_ipython().magic('env')

/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/ipython-0.12-py3.2.egg/IPython/core/interactiveshell.py in magic(self, arg_s, next_input)
   1997                 self._magic_locals = sys._getframe(1).f_locals
   1998             with self.builtin_trap:
-> 1999                 result = fn(magic_args)
   2000             # Ensure we're not keeping object references around:

   2001             self._magic_locals = {}

/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/ipython-0.12-py3.2.egg/IPython/core/magic.py in magic_env(self, parameter_s)
   2923         """List environment variables."""
   2924 
-> 2925         return os.environ.data
   2926 
   2927     def magic_pushd(self, parameter_s=''):

AttributeError: '_Environ' object has no attribute 'data'
Owner

fperez commented Apr 15, 2012

Yup, confirming. @takluyver, since you're our to-go guy for py3, do you want to take a crack at this one? Otherwise I'll get to it, we should definitely fix this before 0.13. Let's make sure we add at least a simple test that just calls %env so it doesn't come back (I'm surprised we didn't have any).

takluyver was assigned Apr 15, 2012

takluyver closed this in e913c0b Apr 15, 2012

@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

@takluyver takluyver Fix %env magic on Python 3.
Closes gh-1201
30f1fa2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment