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

Clean up initialization of the sys module #86168

Closed
serhiy-storchaka opened this issue Oct 10, 2020 · 2 comments
Closed

Clean up initialization of the sys module #86168

serhiy-storchaka opened this issue Oct 10, 2020 · 2 comments
Labels
3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@serhiy-storchaka
Copy link
Member

BPO 42002
Nosy @vstinner, @serhiy-storchaka
PRs
  • bpo-42002: Clean up initialization of the sys module. #22642
  • 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 2020-10-11.14:06:22.416>
    created_at = <Date 2020-10-10.21:01:19.362>
    labels = ['interpreter-core', '3.10']
    title = 'Clean up initialization of the sys module'
    updated_at = <Date 2020-10-11.14:06:22.415>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2020-10-11.14:06:22.415>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-10-11.14:06:22.416>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2020-10-10.21:01:19.362>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42002
    keywords = ['patch']
    message_count = 2.0
    messages = ['378415', '378430']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'serhiy.storchaka']
    pr_nums = ['22642']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue42002'
    versions = ['Python 3.10']

    @serhiy-storchaka
    Copy link
    Member Author

    _PySys_InitCore() and _PySys_InitMain() in Python/sysmodule.c contains many invocations of macros for setting attributes of the sys module. The proposed PR changes these macros.

    1. SET_SYS_FROM_STRING was renamed to just SET_SYS. It is much shorter and allow to write many invocations in one line. Also SET_SYS_FROM_STRING was not consistent with SET_SYS_FROM_WSTR.

    2. Added new SET_SYS_FROM_STRING which sets attribute specified as C char string (similarly to SET_SYS_FROM_WSTR which sets attribute specified as C wchar_t string).

    3. Added COPY_SYS_ATTR for making a copy of the attribute. It uses PyMapping_GetItemString() instead of PyDict_GetItemString() which silences all expressions.

    4. Removed SET_SYS_FROM_STRING_BORROW. It no longer used, and it was used improperly.

    5. SET_SYS_FROM_STRING_INT_RESULT replaced with SET_SYS.

    6. All macros have been rewritten in term of SET_SYS that significantly simplifies the code.

    All this makes the code clearer and makes errors handling more correct.

    @serhiy-storchaka serhiy-storchaka added 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Oct 10, 2020
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset fa1d83d by Serhiy Storchaka in branch 'master':
    bpo-42002: Clean up initialization of the sys module. (GH-22642)
    fa1d83d

    @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
    3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant