Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions comtypes/test/test_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import unittest
from ctypes import (
POINTER,
Expand All @@ -14,21 +13,7 @@
sizeof,
)

PY_3_15 = sys.version_info.major == 3 and sys.version_info.minor == 15

try:
import comtypes.util
except RuntimeError as e:
SKIP_MSG = (
"Starting from Python 3.15, PyCArgObject layout is changed. "
"See https://github.com/enthought/comtypes/issues/938."
)
if PY_3_15:

def setUpModule():
raise unittest.SkipTest(SKIP_MSG)
else:
raise e
import comtypes.util
from comtypes import GUID, CoCreateInstance, IUnknown, shelllink


Expand Down
13 changes: 11 additions & 2 deletions comtypes/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
byref,
c_byte,
c_char,
c_char_p,
c_double,
c_float,
c_int,
c_long,
c_longdouble,
c_longlong,
c_short,
c_ssize_t,
c_void_p,
cast,
sizeof,
Expand All @@ -32,6 +34,13 @@
_T = TypeVar("_T")
_CT = TypeVar("_CT", bound="_CData")

if sys.version_info >= (3, 15):
_TAG_TYPE = c_char_p
_SIZE_TYPE = c_ssize_t
else:
_TAG_TYPE = c_char
_SIZE_TYPE = c_int


def _calc_offset():
# Internal helper function that calculates where the object
Expand Down Expand Up @@ -103,10 +112,10 @@ class value(Union):
_fields_ = [
("PyObject_HEAD", c_byte * object.__basicsize__),
("pffi_type", c_void_p),
("tag", c_char),
("tag", _TAG_TYPE),
("value", value),
("obj", c_void_p),
("size", c_int),
("size", _SIZE_TYPE),
]

_anonymous_ = ["value"]
Expand Down
Loading