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

runfile with path containing apostrophes (quotes) will not work #2158

Closed
spyder-bot opened this issue Feb 17, 2015 · 6 comments
Closed

runfile with path containing apostrophes (quotes) will not work #2158

spyder-bot opened this issue Feb 17, 2015 · 6 comments

Comments

@spyder-bot
Copy link
Collaborator

From mt.bo...@hotmail.com on 2015-02-04T15:53:30Z

Please note that reporting bugs from Spyder's help menu ("?" > "Report
issue...") will fill version details for Spyder, Python and Qt in this description for you.

What steps will reproduce the problem?

  1. When running a file in the spyder python console, it calls runfile('file location') (if I run from the editor-ie, press F5). The problem with this is if the file address contains a folder with an apostrophe in it, it thinks the string has ended there when there is in fact more of the address.

For example:

runfile('C:/Users/username/John's Files/Python/Scripts')

This will attempt to find a file in a folder C:/Users/username/John, which may or may necessarily exist, and regardless the file I wish to execute obviously isn't located there.

I can easily correct this myself by calling the file myself and using double quotes as opposed to single quotes. However, I prefer to run from the editor by pressing F5, and its a bit concerning to me that it defaults to using single quotes when F5 is pressed. I'd rather not have to change all my folder names just so that spyder can run files contained in them.

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

I expect the file to run, and instead I get an invalid syntax error on line 1 of the console What version of the product are you using? On what operating system? spyder 2.3.1 on python 3.4 on windows 8.1

Please provide any additional information below

.

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=2158

@spyder-bot spyder-bot added this to the v2.3.4 milestone Feb 17, 2015
@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2015-02-04T14:12:07Z

Thanks for reporting. I think we need to either:

  1. Escape apostrophes
  2. Change to use double apostrophes (") in runfile

Labels: Cat-Editor MS-v2.3.4

@spyder-bot
Copy link
Collaborator Author

From mt.bo...@hotmail.com on 2015-02-04T20:56:30Z

I think what bothered me most was that the error message and debugging didn't help me pinpoint the issue whatsoever. If it had given me a message like "error: file location could not be found" instead pf just "invalid syntax" I wouldn't have spent so much time trying to figure out what was wrong. I appreciate your timely response and concern.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2015-02-05T07:40:06Z

Sorry for the inconvenience. We didn't expect this corner case, so we didn't take any counter measures about it.

@spyder-bot
Copy link
Collaborator Author

From ZFreeman...@gmail.com on 2015-02-05T19:34:53Z

Correct me if i'm wrong, but solving the problem with solution 2 may not work, in that the double apostrophe character can also be used in filepaths.

@jordanlui
Copy link

Hi there - believe this same issue is still happening for me. I'm a bit new here - let me know if there is some detail I should supply.

Here is what I see in Console:
runfile('D:/Jordan/'s Files/Documents/Dropbox/Coding/Machine Learning/PythonAccuracyTest.py', wdir='D:/Jordan/'s Files/Documents/Dropbox/Coding/Machine Learning')
File "", line 1
runfile('D:/Jordan/'s Files/Documents/Dropbox/Coding/Machine Learning/PythonAccuracyTest.py', wdir='D:/Jordan/'s Files/Documents/Dropbox/Coding/Machine Learning')
^
SyntaxError: invalid syntax

Other console Info:
Python 2.7.12 |Anaconda 4.1.1 (64-bit)| (default, Jun 29 2016, 11:07:13) [MSC v.1500 64 bit (AMD64)]

@ccordoba12
Copy link
Member

@jordanlui, please open a new issue about it, and don't forget to mention your Spyder version. Thanks :-)

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