Skip to content

%run incorrectly expands glob patterns when quoted #12726

Description

@Jwink3101

I think I discovered a bug in how %run works with argv. %run will expand glob patterns even when quoted.

Demo:

First, in terminal:

$ touch foo.txt
$ touch bar.txt

Then make the program demo.py:

import sys
print(sys.argv[1:])

From the command line:

$ python demo.py *.txt
['bar.txt', 'foo.txt']

$ python demo.py "*.txt"
['*.txt']

This is ad you'd expect.

From iPython:

In [1]: %run demo.py *.txt
['foo.txt', 'bar.txt']

In [2]: %run demo.py "*.txt"
['foo.txt', 'bar.txt']

The latter should not be expanded!

Versions

I didn't have time to test this on multiple platforms but this was on macOS Catalina with Anaconda Python:

Python 3.8.3 (default, Jul  2 2020, 11:26:31)
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions