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

exec(open(filename)) doesn't work #47442

Closed
ms mannequin opened this issue Jun 24, 2008 · 8 comments
Closed

exec(open(filename)) doesn't work #47442

ms mannequin opened this issue Jun 24, 2008 · 8 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@ms
Copy link
Mannequin

ms mannequin commented Jun 24, 2008

BPO 3192
Nosy @brettcannon, @leifwalsh
Superseder
  • bpo-1762972: 'exec' does not accept what 'open' returns
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2008-06-26.08:58:37.997>
    created_at = <Date 2008-06-24.20:45:45.963>
    labels = ['interpreter-core', 'type-bug']
    title = "exec(open(filename)) doesn't work"
    updated_at = <Date 2008-06-26.08:58:37.981>
    user = 'https://bugs.python.org/ms'

    bugs.python.org fields:

    activity = <Date 2008-06-26.08:58:37.981>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-06-26.08:58:37.997>
    closer = 'georg.brandl'
    components = ['Interpreter Core']
    creation = <Date 2008-06-24.20:45:45.963>
    creator = 'ms'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 3192
    keywords = []
    message_count = 8.0
    messages = ['68700', '68701', '68702', '68703', '68704', '68705', '68708', '68735']
    nosy_count = 3.0
    nosy_names = ['brett.cannon', 'ms', 'leif.walsh']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '1762972'
    type = 'behavior'
    url = 'https://bugs.python.org/issue3192'
    versions = ['Python 3.0']

    @ms
    Copy link
    Mannequin Author

    ms mannequin commented Jun 24, 2008

    In 2.5, exec(open(filename)), where filename refers to a file with
    python code, executes the code.
    In 2.5, open returns an open file, but in 3.0, open returns a stream,
    and so exec (which wants "a string, file, or code object, not
    TextIOWrapper") returns an error. exec should probably be able to handle
    a stream.

    @ms ms mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jun 24, 2008
    @leifwalsh
    Copy link
    Mannequin

    leifwalsh mannequin commented Jun 24, 2008

    There's 'execfile' in Lib/idlelib/PyShell.py...I'm looking for others.

    There is also a class of functions 'exec*' (and a related class,
    'spawn*') in Lib/os.py that claims to do just what you want, but
    replacing the current process (or, in spawn*'s case, in a new thread).

    That said, I agree that exec should handle streams, and if you could
    give me a heads up as to where the code is for exec(), I could try my
    hand at a patch.

    @ms
    Copy link
    Mannequin Author

    ms mannequin commented Jun 24, 2008

    I'm actually quite new to Python. My current interpreter of choice is
    PostScript, followed by Matlab, but I've been discouraged from using
    either one here at EMC. (PostScript because it's obscure, Matlab because
    it's expensive!)

    Meanwhile, I'm on a wintel machine, making perusing the Python source
    tree difficult. So I'm not going to be much help in that regard.

    By the way, I was told that execfile is gone from python 3.

    --ms

    @leifwalsh
    Copy link
    Mannequin

    leifwalsh mannequin commented Jun 24, 2008

    On Tue, Jun 24, 2008 at 3:05 PM, Mike Speciner <report@bugs.python.org> wrote:

    By the way, I was told that execfile is gone from python 3.

    It certainly isn't in the branch I just checked out.

    @leifwalsh
    Copy link
    Mannequin

    leifwalsh mannequin commented Jun 24, 2008

    (isn't gone, that is)

    @ms
    Copy link
    Mannequin Author

    ms mannequin commented Jun 24, 2008

    Well, I think I found exec in bltinmodule.c,
    but execfile isn't in that file. [In the 3.0 tree.]

    @leifwalsh
    Copy link
    Mannequin

    leifwalsh mannequin commented Jun 24, 2008

    execfile is in Lib/idlelib/PyShell.py, and is an instance function, so
    it's not really standard for regular code, and would also be hard to
    use correctly. Sorry.

    @brettcannon
    Copy link
    Member

    bpo-1762972 supercedes this.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants