-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Some flags are not publicly exported by symtablemodule.c
#120029
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
Comments
Thanks! I merged your PR exposing The other two sound related to comprehension inlining; cc @carljm. |
Yes, that's why I didn't touch them for now. I can easily find an example where exposing |
I haven't checked the code recently but I assume it's used if there's an inner scope inside the listcomp, e.g. |
I see. For now, I'll wait for Carl's opinion on whether the other two flags should be exported. By the way, there are actually two flags that are exported but not imported (and thus not exposed in |
My default position would be that the |
By the way, what is the purpose of the int only_flags = comp_flags & ((1 << SCOPE_OFFSET) - 1);
...
only_flags &= ~DEF_FREE; but AFAICT, |
I'm currently investigating an issue (#119666) related to that line in I don't have any context on the |
I guess |
I looked at the code too and agree DEF_FREE doesn't appear to be doing anything useful. It's publicly exposed but undocumented and has no conceivable use. I think we can remove it in 3.14. |
I have a question on that. Since removing The rationale is that the /* current order */
#define DEF_GLOBAL 1
#define DEF_LOCAL 2
#define DEF_PARAM (2<<1)
#define DEF_NONLOCAL (2<<2)
#define USE (2<<3)
#define DEF_FREE (2<<4)
#define DEF_FREE_CLASS (2<<5)
#define DEF_IMPORT (2<<6)
#define DEF_ANNOT (2<<7)
#define DEF_COMP_ITER (2<<8)
#define DEF_TYPE_PARAM (2<<9)
#define DEF_COMP_CELL (2<<10)
/* suggested order */
#define USE (1 << 0)
#define DEF_ANNOT (1 << 1)
#define DEF_IMPORT (1 << 2)
#define DEF_GLOBAL (1 << 3)
#define DEF_NONLOCAL (1 << 4)
#define DEF_LOCAL (1 << 5)
#define DEF_PARAM (1 << 6)
#define DEF_TYPE_PARAM (1 << 7)
#define DEF_FREE_CLASS (1 << 8)
#define DEF_COMP_ITER (1 << 9)
#define DEF_COMP_CELL (1 << 10) The |
What is the problem with leaving a hole? I'd rather not change the values without a compelling reason. |
Well.. I find it a bit weird to have a hole (but I can revert that change). Actually, I took the opportunity of removing that hold to change the order of the flags (so that the I thought that it could have been a bit nicer to have flags grouped by what they are meant to represent (one specific reason is that I have the If you want to, I split the PR into two, with one PR only removing the deprecated values and another making the change order? |
…iler's flags, add methods (#120099) Expose :class:`symtable.Symbol` methods :meth:`~symtable.Symbol.is_free_class`, :meth:`~symtable.Symbol.is_comp_iter` and :meth:`~symtable.Symbol.is_comp_cell`. --------- Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Carl Meyer <carl@oddbird.net> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
I think we are done with this one or is there something else to do? |
…e compiler's flags, add methods (python#120099) Expose :class:`symtable.Symbol` methods :meth:`~symtable.Symbol.is_free_class`, :meth:`~symtable.Symbol.is_comp_iter` and :meth:`~symtable.Symbol.is_comp_cell`. --------- Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Carl Meyer <carl@oddbird.net> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…e compiler's flags, add methods (python#120099) Expose :class:`symtable.Symbol` methods :meth:`~symtable.Symbol.is_free_class`, :meth:`~symtable.Symbol.is_comp_iter` and :meth:`~symtable.Symbol.is_comp_cell`. --------- Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Carl Meyer <carl@oddbird.net> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…e compiler's flags, add methods (python#120099) Expose :class:`symtable.Symbol` methods :meth:`~symtable.Symbol.is_free_class`, :meth:`~symtable.Symbol.is_comp_iter` and :meth:`~symtable.Symbol.is_comp_cell`. --------- Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Carl Meyer <carl@oddbird.net> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Bug report
Bug description:
The
symtablemodule.c
file does not exportDEF_COMP_ITER
,DEF_TYPE_PARAM
andDEF_COMP_CELL
. Those flags seem to have been added after the original ones so they were probably missed/forgotten. Here is a MWE forDEF_TYPE_PARAM
:By the way, there are tests that are missing for those cases in
test_symtable
, so I can also add the corresponding test. I'm opening a PR now, but feel free to close it if you do not want to expose too many compiler flags (though, I fail to understand why you would do so).CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
DEF_TYPE_PARAM
compiler flag #120028symtable.Symbol.__repr__
correctly reflect the compiler's flags #120099symtable.c
(remove deprecated macros and update some values) #120218symtable.c
#120222The text was updated successfully, but these errors were encountered: