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

Add a "target" parameter to runpy.run_path and runpy.run_module #64181

Open
ncoghlan opened this issue Dec 14, 2013 · 5 comments
Open

Add a "target" parameter to runpy.run_path and runpy.run_module #64181

ncoghlan opened this issue Dec 14, 2013 · 5 comments
Labels
3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@ncoghlan
Copy link
Contributor

BPO 19982
Nosy @brettcannon, @ncoghlan, @ericsnowcurrently, @CuriousLearner, @nanjekyejoannah
Dependencies
  • bpo-19700: Update runpy for PEP 451
  • 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 = None
    created_at = <Date 2013-12-14.13:22:03.091>
    labels = ['type-feature', '3.8']
    title = 'Add a "target" parameter to runpy.run_path and runpy.run_module'
    updated_at = <Date 2019-08-06.17:38:32.963>
    user = 'https://github.com/ncoghlan'

    bugs.python.org fields:

    activity = <Date 2019-08-06.17:38:32.963>
    actor = 'nanjekyejoannah'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = []
    creation = <Date 2013-12-14.13:22:03.091>
    creator = 'ncoghlan'
    dependencies = ['19700']
    files = []
    hgrepos = []
    issue_num = 19982
    keywords = []
    message_count = 5.0
    messages = ['206181', '206430', '305671', '305719', '349121']
    nosy_count = 6.0
    nosy_names = ['brett.cannon', 'ncoghlan', 'eric.snow', 'piotr.dobrogost', 'CuriousLearner', 'nanjekyejoannah']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'needs patch'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue19982'
    versions = ['Python 3.8']

    @ncoghlan
    Copy link
    Contributor Author

    One idea from PEP-451 was to add a "target" parameter to runpy.run_path and runpy.run_module to allow them to support execution in an existing module namespace (like __main__).

    This missed the feature freeze deadline for 3.4, but can be added in 3.5.

    @ncoghlan ncoghlan added the type-feature A feature request or enhancement label Dec 14, 2013
    @ncoghlan
    Copy link
    Contributor Author

    Implementing this is actually likely to require non-trivial restructuring of the runpy internals. contextlib.ExitStack may prove useful in making it easier to programmatically select amongst different context managers.

    The __mp_main__ helpers in multiprocessing should also be able to take advantage of this once it is available, and it may prove useful in finally providing -m analogues for pdb etc that play nice when an exception occurs (see bpo-9325).

    @CuriousLearner
    Copy link
    Member

    Hey ncoghlan,

    Does this issue makes sense to be worked on for Python 3.7?

    @ncoghlan
    Copy link
    Contributor Author

    ncoghlan commented Nov 7, 2017

    See bpo-21862 and bpo-9325 as potential use cases for this feature.

    While it looks like bpo-21862 (-m switch support in cProfile) can be implemented just fine without it, this feature will be needed for the modules that execute the given scripts directly in __main__.__dict__ (e.g. pdb).

    @ncoghlan ncoghlan added the 3.7 (EOL) end of life label Nov 7, 2017
    @ncoghlan ncoghlan added 3.8 only security fixes and removed 3.7 (EOL) end of life labels Jun 4, 2018
    @nanjekyejoannah
    Copy link
    Member

    bpo-19978 also needs this.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Nov 27, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants