hoangKnLai / vscode-ipython

VSCode Extension integrating Editor with IPython console.
MIT License
18 stars 5 forks source link

Run file execution fails (on Linux) #9

Closed FabianHofmann closed 2 years ago

FabianHofmann commented 2 years ago

I am not sure what exactly introduced the error (I hope it was not changes I made in the settings) but the ordinary execution does not work anymore. Also seems to be related to #8

The file execution passes

%run /path/to/python-file.py \

to the console, which apparently does not work due to the escape character... Do you have a fix for that?

Error log:

In [3]: %run /home/bla/bla/file.py \
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-4505fa165e46> in <module>
----> 1 get_ipython().run_line_magic('run', '/home/fabian/vres/py/PowerSimData/powersimdata/input/export_data.py \\')

~/.miniconda3/lib/python3.9/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2362                 kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2363             with self.builtin_trap:
-> 2364                 result = fn(*args, **kwargs)
   2365             return result
   2366 

~/.miniconda3/lib/python3.9/site-packages/decorator.py in fun(*args, **kw)
    230             if not kwsyntax:
    231                 args, kw = fix(args, kw, sig)
--> 232             return caller(func, *(extras + args), **kw)
    233     fun.__name__ = func.__name__
    234     fun.__doc__ = func.__doc__

~/.miniconda3/lib/python3.9/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

~/.miniconda3/lib/python3.9/site-packages/IPython/core/magics/execution.py in run(self, parameter_s, runner, file_finder)
    699 
    700         # get arguments and set sys.argv for program to be run.
--> 701         opts, arg_lst = self.parse_options(parameter_s,
    702                                            'nidtN:b:pD:l:rs:T:em:G',
    703                                            mode='list', list_all=1)

~/.miniconda3/lib/python3.9/site-packages/IPython/core/magic.py in parse_options(self, arg_str, opt_str, *long_opts, **kw)
    625             # If the list of inputs only has 0 or 1 thing in it, there's no
    626             # need to look for options
--> 627             argv = arg_split(arg_str, posix, strict)
    628             # Do regular option processing
    629             try:

~/.miniconda3/lib/python3.9/site-packages/IPython/utils/_process_common.py in arg_split(s, posix, strict)
    200     while True:
    201         try:
--> 202             tokens.append(next(lex))
    203         except StopIteration:
    204             break

~/.miniconda3/lib/python3.9/shlex.py in __next__(self)
    298 
    299     def __next__(self):
--> 300         token = self.get_token()
    301         if token == self.eof:
    302             raise StopIteration

~/.miniconda3/lib/python3.9/shlex.py in get_token(self)
    107             return tok
    108         # No pushback.  Get a token.
--> 109         raw = self.read_token()
    110         # Handle inclusions
    111         if self.source is not None:

~/.miniconda3/lib/python3.9/shlex.py in read_token(self)
    208                         print("shlex: I see EOF in escape state")
    209                     # XXX what error should be raised here?
--> 210                     raise ValueError("No escaped character")
    211                 # In posix shells, only the quote itself or the escape
    212                 # character may be escaped within quotes.

ValueError: No escaped character
hoangKnLai commented 2 years ago

Got it. The escape doesn't work for Linux. Will patch this when I got a chance.

hoangKnLai commented 2 years ago

@FabianHofmann, in the mean time you can instruct VSCode to use the prior working version of the extension.

FabianHofmann commented 2 years ago

@hoangKnLai thank you for the quick response!

hoangKnLai commented 2 years ago

Just patch this by removing the backlash. Please close issue if this fixes the problem. Thanks.

FabianHofmann commented 2 years ago

@hoangKnLai works like charm, I thank you very much!