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

Already on GitHub? Sign in to your account

%edit does not work on filenames consisted of pure numbers #127

Closed
icrazy opened this Issue Jun 6, 2010 · 1 comment

Comments

Projects
None yet
2 participants

icrazy commented Jun 6, 2010

SUMMARY:

I am using ipython 0.10-1ubuntu1 and Python 2.6.5 on Ubuntu 10.04. The magic command '%edit' does not work on filenames consisted of pure numbers, such as '09.py'. Although numbers following '%edit' are interpreted as lines of previous input, in my opinion, a string like '09.py' should be interpreted as a filename for sure.

HOW TO REPEAT THIS PROBLEM:

$ cat 09.py

#!/usr/bin/python

print "hello"

$ cp 09.py a09.py

$ ls
09.py  a09.py

$ ipython
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
...

In [1]: ed -x a09.py
... everything is OK ...

In [2]: ed -x 09.py
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/home/user/test/ in ()

/usr/lib/pymodules/python2.6/IPython/iplib.pyc in ipmagic(self, arg_s)
   1180         else:
   1181             magic_args = self.var_expand(magic_args,1)
-> 1182             return fn(magic_args)
   1183
   1184     def ipalias(self,arg_s):

/usr/lib/pymodules/python2.6/IPython/Magic.py in magic_ed(self, parameter_s)
   2127     def magic_ed(self,parameter_s=''):
   2128         """Alias to %edit."""
-> 2129         return self.magic_edit(parameter_s)
   2130
   2131     @testdec.skip_doctest

/usr/lib/pymodules/python2.6/IPython/Magic.py in magic_edit(self, parameter_s, last_call)
   2323             # numbers this way. Tough.

   2324             ranges = args.split()
-> 2325             data = ''.join(self.extract_input_slices(ranges,opts_r))
   2326         elif args.endswith('.py'):
   2327             filename = make_filename(args)

/usr/lib/pymodules/python2.6/IPython/Magic.py in extract_input_slices(self, slices, raw)
    187                 fin += 1
    188             else:
--> 189                 ini = int(chunk)
    190                 fin = ini+1
    191             cmds.append(hist[ini:fin])

ValueError: invalid literal for int() with base 10: '09.py'
Owner

minrk commented Mar 23, 2011

This is a duplicate of #55 - the restriction is on character 0 specifically.

@minrk minrk closed this Mar 23, 2011

@markvoorhies markvoorhies pushed a commit to markvoorhies/ipython that referenced this issue Apr 21, 2011

@takluyver takluyver Change order in which things are tried in %edit, so filenames startin…
…g with numbers can be edited.


Closes gh-127
Closes gh-55
d43c3dc

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

@takluyver takluyver Change order in which things are tried in %edit, so filenames startin…
…g with numbers can be edited.


Closes gh-127
Closes gh-55
bb3748b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment