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: Delay-loading of python dll is impossible when using some C macros
Type: compile error Stage: resolved
Components: Windows Versions: Python 3.8
process
Status: open Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, Pierre Chatelier, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2017-12-19 13:13 by Pierre Chatelier, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
PythonFromC.zip Pierre Chatelier, 2019-11-19 15:28
Messages (6)
msg308639 - (view) Author: Pierre Chatelier (Pierre Chatelier) Date: 2017-12-19 13:13
Delay-loading of the python DLL is impossible when using some C macros.

For instance, PyLong_Check() is OK, but PyBool_Check() or PyFunc_Check() 
will eventually raise a link error.

This is due to the fact that PyBool_Check() directly use the PyBool_Type symbol instead of getting a reference through a function.

For the same reason, Py_False and Py_True are problematic.
msg356921 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2019-11-18 22:16
Can you give us a case where we can reproduce this locally?
msg356958 - (view) Author: Pierre Chatelier (Pierre Chatelier) Date: 2019-11-19 10:01
Can't reproduce any more.
It might have been specific to the Visual Studio version I used at that time.
msg356971 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2019-11-19 14:52
Thanks for reporting back.  If you find that you can provide a reliable reproducer later, do please reopen and attach it.
msg356972 - (view) Author: Pierre Chatelier (Pierre Chatelier) Date: 2019-11-19 15:17
Just reproduced and solved it at the same time !
It happened with Debug build, where I linked to pythonxx.lib instead of pythonxx_d.lib, because I did not download the debug binaries.
Ultimately : my fault.
msg356973 - (view) Author: Pierre Chatelier (Pierre Chatelier) Date: 2019-11-19 15:28
Aaand finally there is still something : it depends on the call context. Once in a C++/CLI class, the link bug occurs again.
Here is attached a minimal project.
History
Date User Action Args
2022-04-11 14:58:55adminsetgithub: 76552
2019-11-19 15:28:56Pierre Chateliersetversions: + Python 3.8, - Python 3.6
2019-11-19 15:28:49Pierre Chateliersetstatus: closed -> open
files: + PythonFromC.zip
messages: + msg356973
2019-11-19 15:17:42Pierre Chateliersetmessages: + msg356972
2019-11-19 14:52:00zach.waresetstatus: open -> closed
resolution: works for me
messages: + msg356971

stage: resolved
2019-11-19 10:01:52Pierre Chateliersetmessages: + msg356958
2019-11-18 22:16:16BTaskayasetnosy: + BTaskaya
messages: + msg356921
2017-12-19 13:13:18Pierre Chateliercreate