Skip to content

The typical initialization of PyMutex in its comment document cannot be compiled on Windows #115304

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

Closed
aisk opened this issue Feb 11, 2024 · 2 comments
Labels
docs Documentation in the Doc dir

Comments

@aisk
Copy link
Contributor

aisk commented Feb 11, 2024

// Typical initialization:
// PyMutex m = (PyMutex){0};

But it cannot be compiled outside a function on Windows: https://github.com/python/cpython/actions/runs/7862752441/job/21452578591 with this error:

`3>D:\a\cpython\cpython\Modules\rotatingtree.c(19,16): error C2099: initializer is not a constant [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]` 

Also check here be0427f#diff-266bed9d854389a88ddd0696e9a225a2570559901edf0e909de43dd1f49ce80aR19 to see the usage and the compile error.

Change it to PyMutex m = {0}; can resolve this issue.

Linked PRs

@aisk aisk added the docs Documentation in the Doc dir label Feb 11, 2024
aisk added a commit to aisk/cpython that referenced this issue Feb 11, 2024
@terryjreedy
Copy link
Member

I don't understand the links above. pycore_lock.h, 28-29, are as listed, but have nothing obvious to do with commit 2939ad0 for a pydoc fix. Neither do those lines have any obvious connections with the compile error in random_value *= 1082527; in rotatingtree.c. The build report is not obviously linked back to a particular PR.

@aisk
Copy link
Contributor Author

aisk commented Feb 12, 2024

Hi @terryjreedy the compile error in the link should be:

3>D:\a\cpython\cpython\Modules\rotatingtree.c(19,16): error C2099: initializer is not a constant [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj] (I'll update this to the first comment, sorry I forgot it yesterday)

And change the usage to PyMutex m = {0}; got compile passed on Windows, see the commits in #115301

commit 2939ad0 have no connections to this issue, I guess you mixed this with other issues?

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

No branches or pull requests

3 participants