gh-114828: parenthesize non-atomic macro definitions in pycore_symtable.h#115143
gh-114828: parenthesize non-atomic macro definitions in pycore_symtable.h#115143carljm merged 1 commit intopython:mainfrom
Conversation
JelleZijlstra
left a comment
There was a problem hiding this comment.
Thanks for figuring this out!
|
It might be worth backporting this to 3.11, though there will be some conflicts and it's unlikely that we'll make a lot of changes to the 3.11 symtable at this point. Up to you. |
|
Hmm. I think my (weak) inclination is not to backport to 3.11, given that AFAIK there were major symtable changes in 3.12 but not in 3.11, so it seems unlikely we'll be backporting many changes to 3.11, and even less likely that any such changes would be affected by this. This PR is actually a bugfix for 3.12 (given that my But like I say, this is a weak preference, and I'll happily backport to 3.11 if anyone feels strongly that that's the thing to do. |
|
Thanks @carljm for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
…symtable.h (pythonGH-115143) (cherry picked from commit 8f0998e) Co-authored-by: Carl Meyer <[email protected]>
|
GH-115149 is a backport of this pull request to the 3.12 branch. |
In #115139, I used the expression
~DEF_FREEas a mask to clear theDEF_FREEbit in a symbol table entry.Unfortunately,
DEF_FREEis defined as#define DEF_FREE 2<<4, so this macro-expands to~2<<4, and the bitwise negation binds more tightly than the bit-shift, so this actually meant(~2)<<4rather than the~(2<<4)which I intended.This is why non-atomic macro bodies should always be parenthesized!
Fix it by parenthesizing all the non-atomic definitions in
pycore_symtable.h, which not only fixes my~DEF_FREE, but also prevents anyone else making the same mistake in future.