Skip to content
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

PyCMethod_New not defined in python3.lib #87321

Closed
barry-scott mannequin opened this issue Feb 7, 2021 · 9 comments
Closed

PyCMethod_New not defined in python3.lib #87321

barry-scott mannequin opened this issue Feb 7, 2021 · 9 comments
Labels
3.9 only security fixes 3.10 only security fixes

Comments

@barry-scott
Copy link
Mannequin

barry-scott mannequin commented Feb 7, 2021

BPO 43155
Nosy @barry-scott, @vstinner, @encukou, @ZackerySpytz
PRs
  • bpo-43155: Add PyCMethod_New to PC/python3dll.c #24500
  • [3.9] bpo-43155: Add PyCMethod_New to PC/python3dll.c (GH-24500) #24554
  • 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-02-17.10:57:38.946>
    created_at = <Date 2021-02-07.18:05:58.745>
    labels = ['3.9', '3.10']
    title = 'PyCMethod_New not defined in python3.lib'
    updated_at = <Date 2021-02-17.10:57:38.945>
    user = 'https://github.com/barry-scott'

    bugs.python.org fields:

    activity = <Date 2021-02-17.10:57:38.945>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-02-17.10:57:38.946>
    closer = 'vstinner'
    components = []
    creation = <Date 2021-02-07.18:05:58.745>
    creator = 'barry-scott'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43155
    keywords = ['patch']
    message_count = 9.0
    messages = ['386595', '386800', '386870', '386923', '387074', '387075', '387076', '387141', '387143']
    nosy_count = 4.0
    nosy_names = ['barry-scott', 'vstinner', 'petr.viktorin', 'ZackerySpytz']
    pr_nums = ['24500', '24554']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue43155'
    versions = ['Python 3.9', 'Python 3.10']

    @barry-scott
    Copy link
    Mannequin Author

    barry-scott mannequin commented Feb 7, 2021

    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.

    @barry-scott barry-scott mannequin added 3.9 only security fixes 3.10 only security fixes labels Feb 7, 2021
    @barry-scott
    Copy link
    Mannequin Author

    barry-scott mannequin commented Feb 10, 2021

    Is there a test suite that checks that the limited API functions can all be linked against?

    @encukou
    Copy link
    Member

    encukou commented Feb 12, 2021

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

    @barry-scott
    Copy link
    Mannequin Author

    barry-scott mannequin commented Feb 13, 2021

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

    @vstinner
    Copy link
    Member

    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)".

    @vstinner
    Copy link
    Member

    New changeset 8a8b5df by Zackery Spytz in branch 'master':
    bpo-43155: Add PyCMethod_New to PC/python3dll.c (GH-24500)
    8a8b5df

    @vstinner
    Copy link
    Member

    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.

    @vstinner
    Copy link
    Member

    New changeset ebe20d9 by Zackery Spytz in branch '3.9':
    bpo-43155: Add PyCMethod_New to PC/python3.def (GH-24500) (GH-24554)
    ebe20d9

    @vstinner
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants
    @vstinner @encukou and others