-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
The errors that occur when replacing ctypes.windll.foobar
/ctypes.WinDLL("foobar")
with ctypes.oledll.foobar
/ctypes.OleDLL("foobar")
#129010
Comments
I think you are a bit confused. The issue occurs when we replace |
If that’s the case, I was certainly confused. As mentioned in this comment, Therefore, if the goal is to stop the side effects of shared DLL objects, I think that it makes sense to ensure that In any case, this does not seem like a topic that should be addressed in |
I don't follow you. It still seems to be a bug for cpython. Here is a smaller sample to reproduce the problem with OleDLL: OleDLL samplefrom ctypes import OleDLL, c_uint, c_void_p, c_wchar_p
oleaut32 = OleDLL("oleaut32")
SysAllocStringLen = oleaut32.SysAllocStringLen
SysAllocStringLen.argtypes = c_wchar_p, c_uint
SysAllocStringLen.restype = c_void_p
result = SysAllocStringLen("example", 2) Here is the Traceback: Traceback (most recent call last):
File "c:\Users\moi15moi\Desktop\Untitled-1.py", line 9, in <module>
result = SysAllocStringLen("example", 2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "_ctypes/callproc.c", line 1000, in GetResult
OverflowError: Python int too large to convert to C long Here is the exact same code except I replaced WinDLL samplefrom ctypes import WinDLL, c_uint, c_void_p, c_wchar_p
oleaut32 = WinDLL("oleaut32")
SysAllocStringLen = oleaut32.SysAllocStringLen
SysAllocStringLen.argtypes = c_wchar_p, c_uint
SysAllocStringLen.restype = c_void_p
result = SysAllocStringLen("example", 2) There isn't any exception raised. Tested on Python 3.11.7 |
Ah, I finally understand now. Indeed, this is not limited to an issue with I will reopen this issue. |
ctypes.oledll.foobar
with ctypes.OleDLL("foobar")
ctypes.oledll.foobar
/ctypes.OleDLL("foobar")
with ctypes.oledll.foobar
/ctypes.OleDLL("foobar")
ctypes.oledll.foobar
/ctypes.OleDLL("foobar")
with ctypes.oledll.foobar
/ctypes.OleDLL("foobar")
ctypes.windll.foobar
/ctypes.WinDLL("foobar")
with ctypes.oledll.foobar
/ctypes.OleDLL("foobar")
Bug report
Bug description:
In enthought/comtypes#735, @moi15moi suggested avoiding the use of shared DLL objects, and work was attempted to implement this.
Replacing
windll.foobar
withWinDLL("foobar")
andoledll.foobar
withOleDLL("foobar")
seemed like the appropriate approach.However, when using
OleDLL("foobar")
, behavior like the one described in this comment occurred.I had assumed that the only difference between(Edited: I was confused. See #129010 (comment))oledll.foobar
andOleDLL("foobar")
was whether or not they were shared.Could the cause of this behavior lie within the C extension or the
cffi
layer?(See also #129010 (comment) as a minimal reproducer.)
CPython versions tested on:
3.11
Operating systems tested on:
Windows
The text was updated successfully, but these errors were encountered: