byterun
byterun copied to clipboard
Different workaround for http://bugs.python.org/issue19611
This is much less important than the last bug, but I had an issue with the workaround in the code. (This will probably never come up for anyone else, because I'm doing something unusual: using the old pure Python compiler module, not the CPython compile.c).
I think the way I am doing it is slightly simpler though. Since you are constructing
callargs = {'.0': args[0]} anyway, I think you can just check if there is one arg and it is called .0. The name is ignored for LOAD_FAST in favor of the index (lookup by number rather than name), but the name is still emitted.
https://github.com/oilshell/oil/commit/65a504d903abc85b6d3924a0db055dbbdfc03266#diff-702be8382fafa67a707b89a317abc246
- if PY2 and self.func_name in ["<setcomp>", "<dictcomp>", "<genexpr>"]:
+ # Different workaround for issue 19611 that works with
+ # compiler2-generated code. Note that byterun does not use fastlocals,
+ # so the name matters. With fastlocals, the co_varnames entry is just
+ # a comment; the index is used instead.
+ code = self.func_code
+ if code.co_argcount == 1 and code.co_varnames[0] == '.0':