Show More
@@ -276,14 +276,16 b' class IPythonWidget(FrontendWidget):' | |||||
276 | path = os.path.normpath(path).replace('\\', '/') |
|
276 | path = os.path.normpath(path).replace('\\', '/') | |
277 |
|
277 | |||
278 | # Perhaps we should not be using %run directly, but while we |
|
278 | # Perhaps we should not be using %run directly, but while we | |
279 |
# are, it is necessary to quote filenames containing spaces |
|
279 | # are, it is necessary to quote or escape filenames containing spaces | |
280 | # Escaping quotes in filename in %run seems tricky and inconsistent, |
|
280 | # or quotes. As much as possible, we quote: more readable than escape. | |
281 | # so not trying it at present. |
|
|||
282 | if '"' in path: |
|
281 | if '"' in path: | |
283 | if "'" in path: |
|
282 | if "'" in path: | |
284 | raise ValueError("Can't run filename containing both single " |
|
283 | # In this case, because %run 'a\'b"c.py' fails, we must escape | |
285 | "and double quotes: %s" % path) |
|
284 | # all quotes and spaces. | |
286 | path = "'%s'" % path |
|
285 | for c in '" \'': | |
|
286 | path = path.replace(c, '\\'+c) | |||
|
287 | else: | |||
|
288 | path = "'%s'" % path | |||
287 | elif ' ' in path or "'" in path: |
|
289 | elif ' ' in path or "'" in path: | |
288 | path = '"%s"' % path |
|
290 | path = '"%s"' % path | |
289 |
|
291 |
General Comments 0
You need to be logged in to leave comments.
Login now