Skip to content

Conversation

@ariel-anieli
Copy link

Hello maintainers,

Thanks for keeping Python alive; I have been using it for years, and this is my first ever contribution.

runpy.py defines four helpers, and two are not documented using docstrings.

With this change, docstrings are used on all helpers:

# sed -ne '/def /h; /Helper/{x;G;p}' Lib/runpy.py 

def _run_code(code, run_globals, init_globals=None,
    """Helper to run code in nominated namespace"""
def _run_module_code(code, init_globals=None,
    """Helper to run code in new namespace with sys modified"""
def _get_module_details(mod_name, error=ImportError):
    """Helper to get the full name, spec and code for a module"""
def _get_main_module_details(error=ImportError):
    """Helper that gives a nicer error message when attempting to

Your feedback is much appreciated,

@python-cla-bot
Copy link

python-cla-bot bot commented Jun 14, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jun 14, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

runpy.py defines four helpers, and two are not documented using docstrings.

With this change, docstrings are used on all helpers:

> $ sed -ne '/def /h; /Helper/{x;G;p}' Lib/runpy.py
>
> def _run_code(code, run_globals, init_globals=None,
>     """Helper to run code in nominated namespace"""
> def _run_module_code(code, init_globals=None,
>     """Helper to run code in new namespace with sys modified"""
> def _get_module_details(mod_name, error=ImportError):
>     """Helper to get the full name, spec and code for a module"""
> def _get_main_module_details(error=ImportError):
>     """Helper that gives a nicer error message when attempting to

Signed-off-by: Ariel Otilibili <[email protected]>
@ariel-anieli ariel-anieli force-pushed the runpy-docstrings-helpers branch from c9f6ccd to 2635aa5 Compare June 14, 2025 13:04
@bedevere-app
Copy link

bedevere-app bot commented Jun 14, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@AA-Turner
Copy link
Member

Thanks, but I don't think we need this change for private (non-user-facing) callables.

A

@AA-Turner AA-Turner closed this Jun 15, 2025
@ariel-anieli
Copy link
Author

I see, @AA-Turner; thanks for the feedback.

@ariel-anieli ariel-anieli deleted the runpy-docstrings-helpers branch June 16, 2025 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants