This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PyCMethod_New not defined in python3.lib
Type: Stage: resolved
Components: Versions: Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, barry-scott, petr.viktorin, vstinner
Priority: normal Keywords: patch

Created on 2021-02-07 18:05 by barry-scott, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24500 merged ZackerySpytz, 2021-02-10 11:19
PR 24554 merged ZackerySpytz, 2021-02-16 23:42
Messages (9)
msg386595 - (view) Author: Barry Alan Scott (barry-scott) * Date: 2021-02-07 18:05
When using the limited API PyCMethod_New is not defined in python3.lib.
This leads to a link error.

This error is in 3.9 and 3.10a5

Discovered when I improved the PyCXX test suite.

Example output:

Link obj\simple.pyd
        cl /nologo /W4 /LD /Zi /MT /EHsc  /Zi /MT /EHsc -I. -ISrc -IC:\Python310.win64\include -D_CRT_NONSTDC_NO_DEPRECATE -U_DEBUG -DNDEBUG -DPy_LIMITED_API=0x3090000 /Feobj\simple.pyd /Fdobj\simple.pdf obj\simple.obj obj\cxxsupport.obj obj\cxx_extensions.obj obj\cxx_exceptions.obj obj\cxxextensions.obj obj\IndirectPythonInterface.obj C:\Python310.win64\libs\python3.lib
   Creating library obj\simple.lib and object obj\simple.exp
simple.obj : error LNK2019: unresolved external symbol __imp_PyCMethod_New referenced in function "protected: virtual class Py::Object __cdecl Py::PythonExtension<class old_style_class>::getattr_methods(char const *)" (?getattr_methods@?$PythonExtension@Vold_style_class@@@Py@@MEAA?AVObject@2@PEBD@Z)
obj\simple.pyd : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.EXE"' : return code '0x2'
Stop.
msg386800 - (view) Author: Barry Alan Scott (barry-scott) * Date: 2021-02-10 19:16
Is there a test suite that checks that the limited API functions can all be linked against?
msg386870 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2021-02-12 18:21
> Is there a test suite that checks that the limited API functions can all be linked against?

Not yet. There's not even consensus about exactly what functions are part of the limited API.
I plan to address both issues in PEP 652 (currently in Draft status).
msg386923 - (view) Author: Barry Alan Scott (barry-scott) * Date: 2021-02-13 12:17
Thanks Petr, I'll watch for the PEP.

FYI: I work on the assumption that if I use Py_LIMITED_API and the header
files provide an API guarded by an #if then its "offical".
msg387074 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-02-16 00:13
> Is there a test suite that checks that the limited API functions can all be linked against?

Pablo Galindo wrote a new Tools/scripts/stable_abi.py for Unix, but this tool doesn't check PC/python3dll.c yet. The tool uses Doc/data/stable_abi.dat which *does* include PyCMethod_New symbol.

I created bpo-43235 "Tools/scripts/stable_abi.py should also check PC/python3dll.c (Windows stable ABI)".
msg387075 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-02-16 00:14
New changeset 8a8b5df93f379f561aab4f2fc5b2ad54f5009f7a by Zackery Spytz in branch 'master':
bpo-43155: Add PyCMethod_New to PC/python3dll.c (GH-24500)
https://github.com/python/cpython/commit/8a8b5df93f379f561aab4f2fc5b2ad54f5009f7a
msg387076 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-02-16 00:16
The symbol was exported on Unix since Python 3.9.0, but not on Windows. Is it ok to export it starting with Python 3.9.2? (backport the fix). IMO yes, it's ok.
msg387141 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-02-17 10:53
New changeset ebe20d9e7eb138c053958bc0a3058d34c6e1a679 by Zackery Spytz in branch '3.9':
bpo-43155: Add PyCMethod_New to PC/python3.def (GH-24500) (GH-24554)
https://github.com/python/cpython/commit/ebe20d9e7eb138c053958bc0a3058d34c6e1a679
msg387143 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-02-17 10:57
Thanks Barry for the bug report and thanks Zackery for the fix! It's now fixed.

See bpo-43235 and bpo-43239 follow-up issues.
History
Date User Action Args
2022-04-11 14:59:41adminsetgithub: 87321
2021-02-17 10:57:38vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg387143

stage: patch review -> resolved
2021-02-17 10:53:48vstinnersetmessages: + msg387141
2021-02-16 23:42:30ZackerySpytzsetpull_requests: + pull_request23336
2021-02-16 00:16:37vstinnersetmessages: + msg387076
2021-02-16 00:14:33vstinnersetmessages: + msg387075
2021-02-16 00:13:46vstinnersetnosy: + vstinner
messages: + msg387074
2021-02-13 12:17:19barry-scottsetmessages: + msg386923
2021-02-12 18:21:22petr.viktorinsetnosy: + petr.viktorin
messages: + msg386870
2021-02-10 19:16:19barry-scottsetmessages: + msg386800
2021-02-10 11:19:02ZackerySpytzsetkeywords: + patch
nosy: + ZackerySpytz

pull_requests: + pull_request23289
stage: patch review
2021-02-07 18:05:58barry-scottcreate