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

zstandard.MAGIC_NUMBER returns wrong value on Windows #202

Open
123456abcdef opened this issue Sep 8, 2023 · 1 comment
Open

zstandard.MAGIC_NUMBER returns wrong value on Windows #202

123456abcdef opened this issue Sep 8, 2023 · 1 comment

Comments

@123456abcdef
Copy link

I encountered the following problem.

Linux environment

Python 3.11.3
zstandard 0.21.0

>>> import zstandard
>>> hex(zstandard.MAGIC_NUMBER)
'0xfd2fb528'

Win10 environment

Python 3.9.16
zstandard 0.21.0

>>> import zstandard
>>> hex(zstandard.MAGIC_NUMBER)
'-0x2d04ad8'

It seems to be a OS specific difference not related to the Python version. Why is there a difference?

@enkore
Copy link

enkore commented Mar 25, 2024

PyModule_AddIntConstant takes a long, linux is unix is LP64, so long is 64-bits wide, windows is LLP64, so long is 32-bits wide, so that highest set bit makes it negative on windows.

Fix would be using PyLong_FromLongLong and PyModule_AddObjectRef.

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

2 participants