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

DmtxTime bug #94

Open
shuaifeifan opened this issue Feb 17, 2023 · 0 comments
Open

DmtxTime bug #94

shuaifeifan opened this issue Feb 17, 2023 · 0 comments

Comments

@shuaifeifan
Copy link

the size of 'sec' in DmtxTime(wrapper.py) is fixed to c_ulonglong which is not always true, it should keep the same size with time_t in C library. since time_t can be 32bits or 64bits according the exactly system, the defination of sec should also be changed by system. next patch can fix this problem(refer from: python/cpython#92869)

import platform
import ctypes
......
time_t=ctypes.c_int64
if platform.system() == 'Windows':
# Assume MSVC(?) - what about mingw/clang?
time_t = ctypes.c_int64
elif ctypes.sizeof(ctypes.c_void_p) == ctypes.sizeof(ctypes.c_int64):
# 64-bit platform of any kind - assume 64-bit time_t(?)
time_t = ctypes.c_int64
else:
# assume some kind of 32-bit platform(?)
time_t = ctypes.c_int32

class DmtxTime(Structure):
fields = [
#('sec', c_ulong), # Actually a time_t
('sec',time_t),
('usec', c_ulong),
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant