GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [C API] Deprecate legacy API for configure Python initialization · Issue #88279 · python/cpython

[C API] Deprecate legacy API for configure Python initialization #88279

New issue
Copy link
New issue
Copy link
Closed
Closed
[C API] Deprecate legacy API for configure Python initialization#88279
Copy link
Labels
3.11only security fixesonly security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirtopic-C-API

Description

@vstinner
vstinner
opened on May 12, 2021
Issue body actions
BPO 44113
Nosy @vstinner, @corona10, @joukewitteveen
PRs
  • bpo-44113: Deprecate old functions to config Python init #26060
  • bpo-43956: Doc/c-api: Fix default program name #24876
  • bpo-44113: Update __xxtestfuzz not to use Py_SetProgramName #26083
  • bpo-44113: Fix compiler warning in PySys_AddWarnOption() #26084
  • bpo-44113: Update fromzenmain not to use Py_SetProgramName #26085
  • bpo-44113: Move the What's New entry to Deprecate section #28974
  • 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 2021-05-14.12:21:54.201>
    created_at = <Date 2021-05-12.10:20:54.214>
    labels = ['expert-C-API', '3.11', 'docs']
    title = '[C API] Deprecate legacy API for configure Python initialization'
    updated_at = <Date 2021-10-15.11:43:51.791>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2021-10-15.11:43:51.791>
    actor = 'vstinner'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2021-05-14.12:21:54.201>
    closer = 'vstinner'
    components = ['Documentation', 'C API']
    creation = <Date 2021-05-12.10:20:54.214>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44113
    keywords = ['patch']
    message_count = 8.0
    messages = ['393499', '393550', '393551', '393553', '393641', '393647', '393648', '404005']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'docs@python', 'corona10', 'joukewitteveen']
    pr_nums = ['26060', '24876', '26083', '26084', '26085', '28974']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue44113'
    versions = ['Python 3.11']

    Activity

    Next
    1. vstinner commented on May 12, 2021

      @vstinner
      vstinner
      on May 12, 2021
      MemberAuthor
      More actions

      The https://docs.python.org/dev/c-api/init.html documentation lists many functions which is the legacy way to configure the Python initialization. These functions are kept for backward compatibility but have flaws and are less reliable than the new PyConfig API (PEP-587) documented at https://docs.python.org/dev/c-api/init_config.html

      I propose to deprecate the legacy functions to configure the Python initialization. Examples:

      • Py_SetPath()
      • Py_SetProgramName()
      • Py_SetPythonHome()
      • Py_SetStandardStreamEncoding()
      • PySys_AddWarnOption()
      • PySys_AddWarnOptionUnicode()
      • PySys_AddXOption()

      I don't propose to schedule the removal of these functions, only mark them as deprecated in the *documentation*.

      Related issue: bpo-43956 "C-API: Incorrect default value for Py_SetProgramName" and PR 24876.

    2. vstinner
      added
      3.11only security fixesonly security fixes
      on May 12, 2021
    3. vstinner
      assigned
      docspython
      on May 12, 2021
    4. vstinner
      added
      docsDocumentation in the Doc dirDocumentation in the Doc dir
      topic-C-API
      3.11only security fixesonly security fixes
      on May 12, 2021
    5. vstinner
      assigned
      docspython
      on May 12, 2021
    6. vstinner
      added
      docsDocumentation in the Doc dirDocumentation in the Doc dir
      topic-C-API
      on May 12, 2021
    7. vstinner commented on May 12, 2021

      @vstinner
      vstinner
      on May 12, 2021
      MemberAuthor
      More actions

      PyConfig API was added to Python 3.8, so it's now widely available. Python 3.8 always switched to security fixes only phase. So IMO it's ok to deprecate the old API now.

    8. vstinner commented on May 12, 2021

      @vstinner
      vstinner
      on May 12, 2021
      MemberAuthor
      More actions

      """
      Check warning on line 82 in Python/frozenmain.c
      GitHub Actions / Ubuntu
      ‘Py_SetProgramName’ is deprecated [-Wdeprecated-declarations]
      """

      Well, Py_FrozenMain() should be rewritten with PyConfig, I want to do that for a long time, but I don't know how to test it. It would be nice to have a very basic test for Py_FrozenMain().

      See also:
      https://mail.python.org/archives/list/[email protected]/thread/5QLI3NUP3OSGLCCIBAQOTX4GEJQBWJ6F/

    9. vstinner commented on May 13, 2021

      @vstinner
      vstinner
      on May 13, 2021
      MemberAuthor
      More actions

      commit 6cd0446
      Author: Victor Stinner <[email protected]>
      Date: Wed May 12 23:59:25 2021 +0200

      bpo-44113: Deprecate old functions to config Python init (GH-26060)
      
      Deprecate the following functions to configure the Python
      initialization:
      
      * PySys_AddWarnOption()
      * PySys_AddWarnOptionUnicode()
      * PySys_AddXOption()
      * PySys_HasWarnOptions()
      * Py_SetPath()
      * Py_SetProgramName()
      * Py_SetPythonHome()
      * Py_SetStandardStreamEncoding()
      * _Py_SetProgramFullPath()
      
      Use the new PyConfig API of the Python Initialization Configuration
      instead (PEP-587).
      

      commit a0ccc40
      Author: Dong-hee Na <[email protected]>
      Date: Thu May 13 08:22:18 2021 +0900

      bpo-44113: Update __xxtestfuzz not to use Py_SetProgramName (GH-26083)
      

      commit ec7c09b
      Author: Victor Stinner <[email protected]>
      Date: Thu May 13 02:27:56 2021 +0200

      bpo-44113: Fix compiler warning in PySys_AddWarnOption() (GH-26084)
      
      Ignore Py_DEPRECATED() warning on purpose.
      
    10. vstinner commented on May 14, 2021

      @vstinner
      vstinner
      on May 14, 2021
      MemberAuthor
      More actions

      commit 7565586
      Author: Dong-hee Na <[email protected]>
      Date: Thu May 13 10:19:46 2021 +0900

      bpo-44113: Update fromzenmain not to use Py_SetProgramName (GH-26085)
      
    11. vstinner commented on May 14, 2021

      @vstinner
      vstinner
      on May 14, 2021
      MemberAuthor
      More actions

      Well, Py_FrozenMain() should be rewritten with PyConfig, I want to do that for a long time, but I don't know how to test it. It would be nice to have a very basic test for Py_FrozenMain().

      I created bpo-44131: [C API] Add tests on Py_FrozenMain().

    12. vstinner commented on May 14, 2021

      @vstinner
      vstinner
      on May 14, 2021
      MemberAuthor
      More actions

      Thanks for the help Dong-hee ;-) I close the issue, functions are now deprecated.

    13. 1 remaining item

    14. vstinner
      closed this as completedon May 14, 2021
    15. vstinner commented on Oct 15, 2021

      @vstinner
      vstinner
      on Oct 15, 2021
      MemberAuthor
      More actions

      New changeset a7f8dfd by Victor Stinner in branch 'main':
      bpo-44113: Move the What's New entry to Deprecate section (GH-28974)
      a7f8dfd

    16. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    17. vstinner
      reopened this on May 6, 2022
    18. vstinner
      added a commit that references this issue on May 6, 2022

      gh-88279: Deprecate PySys_SetArgvEx() (#92363)

      299692a
    19. serhiy-storchaka
      added a commit that references this issue on May 7, 2022

      pythongh-88279: Fix compiler warning for using deprecated PySys_SetAr…

      16953b4
    20. pablogsal
      added a commit that references this issue on May 7, 2022

      gh-88279: Fix compiler warning for using deprecated PySys_SetArgvEx (#…

      bd030b6
    21. miss-islington
      added 2 commits that reference this issue on May 8, 2022

      pythongh-88279: Fix compiler warning for using deprecated PySys_SetAr…

      ecaf642

      gh-88279: Fix compiler warning for using deprecated PySys_SetArgvEx (G…

      14bd6df
    22. saagarjha
      added a commit that references this issue on Jul 20, 2022

      Handle Python 3.11 deprecation of PySys_SetPath and Py_SetProgramName

      fe587fc
    23. vstinner
      closed this as completedon Nov 3, 2022
    24. milianw commented on Jan 10, 2024

      @milianw
      milianw
      on Jan 10, 2024
      More actions

      Hey there, I'm unsure if this is the right place to ask - if not, please guide me elsewhere.

      How are projects using the limited python API supposed to port away from the deprecated API? The "new" API in cpython/initconfig.h is guarded behind a #ifndef Py_LIMITED_API and thus not accessible...

      Can you please make this API available through the limited API, or revert the decision to deprecate this API?

      Thanks

    25. encukou commented on Jan 16, 2024

      @encukou
      encukou
      on Jan 16, 2024
      Member
      More actions

      The proper place is here: #105145
      Apparently, the new API is available widely enough.

    26. vstinner commented on Jan 16, 2024

      @vstinner
      vstinner
      on Jan 16, 2024
      MemberAuthor
      More actions

      How are projects using the limited python API supposed to port away from the deprecated API?

      I suggest to continue in the dedicated issue: #107954 "No limited C API to customize Python initialization (PyConfig, PEP 587)"

      I worked on two projects for the limited C API:

      • Stable ABI to configure Python initialization: [PEP 741] gh-107954: Add PyInitConfig C API #110176
      • Stable ABI to get the current Python configuration: [PEP 741] gh-107954: Add PyConfig_Get() function #112609 => Add PyConfig_Get() and PyConfig_GetInt() functions capi-workgroup/decisions#3

      So far, I had to put this work aside since I had too many things on my plate.

    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.11only security fixesonly security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirtopic-C-API

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402503 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.