Skip to content

gh-105922: Add PyImport_AddModuleRef() function #105923

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

Merged
merged 1 commit into from
Jun 20, 2023

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 19, 2023

  • Add tests on PyImport_AddModuleRef(), PyImport_AddModule() and
    PyImport_AddModuleObject().
  • pythonrun.c: Replace Py_XNewRef(PyImport_AddModule(name)) with
    PyImport_AddModuleRef(name).

📚 Documentation preview 📚: https://cpython-previews--105923.org.readthedocs.build/

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice; I left some comments.

Too bad we cannot run the ref leak bots now; there's already a ref leak in test_import and test_peg_generator that has not been resolved :(

@vstinner vstinner force-pushed the pyimport_addmoduleref branch from 631c02c to bf2a756 Compare June 19, 2023 23:08
@vstinner
Copy link
Member Author

I updated my PR:

  • Rebased on the merged pythonrunc.c refactoring: commit a5c2ad0
  • Don't deprecate PyImport_AddModule() and PyImport_AddModuleObject() in this PR anymore: I prefer to handle this in a separated PR.
  • Fix pythonrun.c
  • Use PyImport_AddModuleRef() for _frozen_importlib

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo nit. Otherwise looks good to me.

* Add tests on PyImport_AddModuleRef(), PyImport_AddModule() and
  PyImport_AddModuleObject().
* pythonrun.c: Replace Py_XNewRef(PyImport_AddModule(name)) with
  PyImport_AddModuleRef(name).
@vstinner
Copy link
Member Author

I fixed the typo: similar than => similar to.

@vstinner vstinner force-pushed the pyimport_addmoduleref branch from 22c5f8c to f3a223d Compare June 20, 2023 00:36
@vstinner vstinner merged commit 03f1a13 into python:main Jun 20, 2023
@vstinner vstinner deleted the pyimport_addmoduleref branch June 20, 2023 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants