Skip to content

Clean up initialization of the sys module #86168

Closed

Description

@serhiy-storchaka
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']

    Activity

    1. serhiy-storchaka commented on Oct 10, 2020

      @serhiy-storchaka
      MemberAuthor

      _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.

    2. added
      3.10 (EOL)
      interpreter-core
      on Oct 10, 2020
    3. serhiy-storchaka commented on Oct 11, 2020

      @serhiy-storchaka
      MemberAuthor

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

    4. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.10 (EOL)interpreter-core

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions