Show More
@@ -277,18 +277,13 b' class IPythonWidget(FrontendWidget):' | |||
|
277 | 277 | |
|
278 | 278 | # Perhaps we should not be using %run directly, but while we |
|
279 | 279 | # are, it is necessary to quote or escape filenames containing spaces |
|
280 | # or quotes. As much as possible, we quote: more readable than escape. | |
|
281 | if '"' in path: | |
|
280 | # or quotes. Note that in this context, because run uses posix | |
|
281 | # parsing, we can escape double quotes in a double quoted filename, | |
|
282 | # but can't escape singe quotes in a single quoted filename. | |
|
282 | 283 |
|
|
283 | # In this case, because %run 'a\'b"c.py' fails, we must escape | |
|
284 | # all quotes and spaces. | |
|
285 | for c in '" \'': | |
|
286 | path = path.replace(c, '\\'+c) | |
|
287 | else: | |
|
284 | path = '"%s"' % path.replace('"', '\\"') | |
|
285 | elif ' ' in path or '"' in path: | |
|
288 | 286 |
|
|
289 | elif ' ' in path or "'" in path: | |
|
290 | path = '"%s"' % path | |
|
291 | ||
|
292 | 287 | self.execute('%%run %s' % path, hidden=hidden) |
|
293 | 288 | |
|
294 | 289 | #--------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now