Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-110964: Remove private _PyArg functions#110966

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 2 commits intopython:mainfromvstinner:pycore_modsupport
Oct 17, 2023

Conversation

vstinner
Copy link
Member

@vstinnervstinner commentedOct 17, 2023
edited by bedevere-appbot
Loading

Move the following private functions and structures to pycore_modsupport.h internal C API:

  • _PyArg_BadArgument()
  • _PyArg_CheckPositional()
  • _PyArg_NoKeywords()
  • _PyArg_NoPositional()
  • _PyArg_ParseStack()
  • _PyArg_ParseStackAndKeywords()
  • _PyArg_Parser structure
  • _PyArg_UnpackKeywords()
  • _PyArg_UnpackKeywordsWithVararg()
  • _PyArg_UnpackStack()
  • _Py_ANY_VARARGS()

Changes:

  • Python/getargs.h now includes pycore_modsupport.h to export functions.

  • clinic.py now adds pycore_modsupport.h when one of these functions is used.

  • Add pycore_modsupport.h includes when a C extension uses one of these functions.

  • Define Py_BUILD_CORE_MODULE in C extensions which now include directly or indirectly (via code generated by Argument Clinic) pycore_modsupport.h:

    • _csv
    • _curses_panel
    • _dbm
    • _gdbm
    • _multiprocessing.posixshmem
    • _sqlite.row
    • _statistics
    • grp
    • resource
    • syslog
  • _testcapi: bad_get() no longer uses METH_FASTCALL calling convention but METH_VARARGS. Replace _PyArg_UnpackStack() with PyArg_ParseTuple().

  • _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined by _testcapi sub-modules which need the internal C API (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c, watchers.c.

  • Remove Include/cpython/modsupport.h header file. Include/modsupport.h no longer includes the removed header file.

@vstinner
Copy link
MemberAuthor

This change is big because it changes 122 files generated by Argument Clinic:

$ git show --stat|grep 'clinic/.*.c.h'|wc -l122

I prefer to write a single PR to move all private _PyArg functions at once,because each moved function touch many files generated by AC.

Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

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

The AC changes look fine to me! (I'll leave the question of whether the changes are worth making to those more skilled in C.)

Move the following private functions and structures topycore_modsupport.h internal C API:* _PyArg_BadArgument()* _PyArg_CheckPositional()* _PyArg_NoKeywords()* _PyArg_NoPositional()* _PyArg_ParseStack()* _PyArg_ParseStackAndKeywords()* _PyArg_Parser structure* _PyArg_UnpackKeywords()* _PyArg_UnpackKeywordsWithVararg()* _PyArg_UnpackStack()* _Py_ANY_VARARGS()Changes:* Python/getargs.h now includes pycore_modsupport.h to export  functions.* clinic.py now adds pycore_modsupport.h when one of these functions  is used.* Add pycore_modsupport.h includes when a C extension uses one of  these functions.* Define Py_BUILD_CORE_MODULE in C extensions which now include  directly or indirectly (via code generated by Argument Clinic)  pycore_modsupport.h:  * _csv  * _curses_panel  * _dbm  * _gdbm  * _multiprocessing.posixshmem  * _sqlite.row  * _statistics  * grp  * resource  * syslog* _testcapi: bad_get() no longer uses METH_FASTCALL calling  convention but METH_VARARGS. Replace _PyArg_UnpackStack() with  PyArg_ParseTuple().* _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined  by _testcapi sub-modules which need the internal C API  (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c,  watchers.c.* Remove Include/cpython/modsupport.h header file.  Include/modsupport.h no longer includes the removed header file.* Fix mypy clinic.py
@vstinner
Copy link
MemberAuthor

For clinic.py, I was lazy and used theclinic global variable inbad_argument(). The correct fix is to pass aclinic argument to addbad_argument() methods and calling sites. Problem: there aremany. Second problem: I wrote such change many times, but I lost my work since the overall change was blocked for different reasons. Also, I tried to keep this PR as small as possible.

In short, clinic.py should be reworked later, once this change lands.

AlexWaygood reacted with thumbs up emoji

Comment on lines +3523 to +3524
if clinic is not None:
clinic.add_include('pycore_modsupport.h', '_PyArg_BadArgument()')
Copy link
Member

Choose a reason for hiding this comment

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

or perhaps this?

Suggested change
ifclinicisnotNone:
clinic.add_include('pycore_modsupport.h','_PyArg_BadArgument()')
assertclinicisnotNone
clinic.add_include('pycore_modsupport.h','_PyArg_BadArgument()')

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

As explained in my previous comment, I plan to write a follow-up for this code. We should not use the global variable, but pass an argument whichcannot be None.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I agree that's the more principled action in the longer term, and I'm fine with using the easier solution for now. But this is the same number of lines, and I think makes it clearer that we never expectclinic to beNone here (if it isNone, something has gone horribly wrong :-)

erlend-aasland reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

PR to refactor this code, to avoidif clinic is not None: PR#110982.

@vstinnervstinner merged commitbe5e8a0 intopython:mainOct 17, 2023
@vstinnervstinner deleted the pycore_modsupport branchOctober 17, 2023 12:30
@vstinner
Copy link
MemberAuthor

For clinic.py, I was lazy and used the clinic global variable in bad_argument().

I wrote PR#110984 for that.

@vstinner
Copy link
MemberAuthor

I merged my PR.@AlexWaygood: thanks for reviewing clinic.py changes.

AlexWaygood reacted with thumbs up emoji

aisk pushed a commit to aisk/cpython that referenced this pull requestFeb 11, 2024
Move the following private functions and structures topycore_modsupport.h internal C API:* _PyArg_BadArgument()* _PyArg_CheckPositional()* _PyArg_NoKeywords()* _PyArg_NoPositional()* _PyArg_ParseStack()* _PyArg_ParseStackAndKeywords()* _PyArg_Parser structure* _PyArg_UnpackKeywords()* _PyArg_UnpackKeywordsWithVararg()* _PyArg_UnpackStack()* _Py_ANY_VARARGS()Changes:* Python/getargs.h now includes pycore_modsupport.h to export  functions.* clinic.py now adds pycore_modsupport.h when one of these functions  is used.* Add pycore_modsupport.h includes when a C extension uses one of  these functions.* Define Py_BUILD_CORE_MODULE in C extensions which now include  directly or indirectly (via code generated by Argument Clinic)  pycore_modsupport.h:  * _csv  * _curses_panel  * _dbm  * _gdbm  * _multiprocessing.posixshmem  * _sqlite.row  * _statistics  * grp  * resource  * syslog* _testcapi: bad_get() no longer uses METH_FASTCALL calling  convention but METH_VARARGS. Replace _PyArg_UnpackStack() with  PyArg_ParseTuple().* _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined  by _testcapi sub-modules which need the internal C API  (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c,  watchers.c.* Remove Include/cpython/modsupport.h header file.  Include/modsupport.h no longer includes the removed header file.* Fix mypy clinic.py
hroncok added a commit to hroncok/pygame that referenced this pull requestJun 18, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull requestSep 2, 2024
Move the following private functions and structures topycore_modsupport.h internal C API:* _PyArg_BadArgument()* _PyArg_CheckPositional()* _PyArg_NoKeywords()* _PyArg_NoPositional()* _PyArg_ParseStack()* _PyArg_ParseStackAndKeywords()* _PyArg_Parser structure* _PyArg_UnpackKeywords()* _PyArg_UnpackKeywordsWithVararg()* _PyArg_UnpackStack()* _Py_ANY_VARARGS()Changes:* Python/getargs.h now includes pycore_modsupport.h to export  functions.* clinic.py now adds pycore_modsupport.h when one of these functions  is used.* Add pycore_modsupport.h includes when a C extension uses one of  these functions.* Define Py_BUILD_CORE_MODULE in C extensions which now include  directly or indirectly (via code generated by Argument Clinic)  pycore_modsupport.h:  * _csv  * _curses_panel  * _dbm  * _gdbm  * _multiprocessing.posixshmem  * _sqlite.row  * _statistics  * grp  * resource  * syslog* _testcapi: bad_get() no longer uses METH_FASTCALL calling  convention but METH_VARARGS. Replace _PyArg_UnpackStack() with  PyArg_ParseTuple().* _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined  by _testcapi sub-modules which need the internal C API  (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c,  watchers.c.* Remove Include/cpython/modsupport.h header file.  Include/modsupport.h no longer includes the removed header file.* Fix mypy clinic.py
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@AlexWaygoodAlexWaygoodAlexWaygood left review comments

@erlend-aaslanderlend-aaslandAwaiting requested review from erlend-aaslanderlend-aasland is a code owner

@corona10corona10Awaiting requested review from corona10corona10 is a code owner

@ethanfurmanethanfurmanAwaiting requested review from ethanfurmanethanfurman is a code owner

@rhettingerrhettingerAwaiting requested review from rhettingerrhettinger is a code owner

@berkerpeksagberkerpeksagAwaiting requested review from berkerpeksagberkerpeksag is a code owner

@pgansslepganssleAwaiting requested review from pgansslepganssle is a code owner

@abalkinabalkinAwaiting requested review from abalkinabalkin is a code owner

@brettcannonbrettcannonAwaiting requested review from brettcannonbrettcannon is a code owner

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

@ncoghlanncoghlanAwaiting requested review from ncoghlanncoghlan is a code owner

@warsawwarsawAwaiting requested review from warsawwarsaw is a code owner

@tirantiranAwaiting requested review from tirantiran is a code owner

@iritkatrieliritkatrielAwaiting requested review from iritkatrieliritkatriel is a code owner

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

@1st11st1Awaiting requested review from 1st11st1 is a code owner

@asvetlovasvetlovAwaiting requested review from asvetlovasvetlov is a code owner

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

@kumaraditya303kumaraditya303Awaiting requested review from kumaraditya303kumaraditya303 is a code owner

@willingcwillingcAwaiting requested review from willingcwillingc is a code owner

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@vstinner@AlexWaygood

[8]ページ先頭

©2009-2025 Movatter.jp