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

Cannot runcell if double backslash is present #8241

Closed
2 tasks done
jnsebgosselin opened this issue Nov 14, 2018 · 5 comments · Fixed by #8243
Closed
2 tasks done

Cannot runcell if double backslash is present #8241

jnsebgosselin opened this issue Nov 14, 2018 · 5 comments · Fixed by #8243

Comments

@jnsebgosselin
Copy link
Member

jnsebgosselin commented Nov 14, 2018

Issue Report Checklist

  • Searched the issues page for similar reports
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

@bcolsen

I think this was introduced in PR #7310. I was not able to reproduce the error when checking out to 29e0623.

What steps reproduce the problem?

  1. Create a new file with the following content in the Editor :
# -*- coding: utf-8 -*-
#%%

dirname = ("C:\\Users\\User\\test.py")

# %%
  1. Run the cell (Ctrl + Enter or Shift + Enter).

What is the expected output? What do you see instead?

dirname should be defined in the current console, but an error is raised instead.

Paste Traceback/Error Below (if applicable)

runcell('','C:/Users/User/Desktop/test.py')
  File "<ipython-input-26-0a3ec57e3b80>", line 4
    dirname = ("C:\Users\User\test.py")
              ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Versions

  • Spyder version: Spyder 4.0.0.dev0 4479343
  • Python version: Python 3.6.6 64-bit
  • Qt version: Qt 5.6.2
  • PyQt version: PyQt5 5.6
  • Operating System name/version: Windows 10

Dependencies

pygments >=2.0    :  2.2.0 (OK)
sphinx >=0.6.6    :  1.8.1 (OK)
pyls >=0.19.0     :  0.19.0 (OK)
nbconvert >=4.0   :  5.3.1 (OK)
pandas >=0.13.1   :  0.23.4 (OK)
numpy >=1.7       :  1.15.2 (OK)
sympy >=0.7.3     :  None (NOK)
cython >=0.21     :  None (NOK)
qtconsole >=4.2.0 :  4.5.0.dev0 (OK)
IPython >=4.0     :  7.0.1 (OK)
matplotlib >=2.0.0:  None (NOK)
pylint >=0.25     :  2.1.1 (OK)
@ccordoba12
Copy link
Member

@bcolsen, could you take a look at this one? Thanks!

@bcolsen
Copy link
Member

bcolsen commented Nov 14, 2018

It looks like the escape /'s are being remove before running the cell.

I get the same error running:

In [112]: dirname = ('C:\Users\User\test.py')
  File "<ipython-input-112-09e9a480868a>", line 1
    dirname = ('C:\Users\User\test.py')
              ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

I can test this tonight but I think a 'r"""{}"""') on this line might work:

@ccordoba12
Copy link
Member

Yep, I was thinking an r would help to solve this.

@jnsebgosselin
Copy link
Member Author

Cool, thank you very much for taking care of this! This is a little bit annoying hehe

@bcolsen
Copy link
Member

bcolsen commented Nov 15, 2018

I actually ran into this one myself this afternoon with a \n :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants