Comments (11)
Thanks for the report. Could you make a PR adding LOAD_CONST to _stack_effects so that we avoid the offending call ? Add a test and an entry in the changlog.
from bytecode.
Very glad to do that. I'll make it done.
from bytecode.
I can't reproduce the error. What python version do you use?
from bytecode.
I did not have time to try to reproduce but the line 34 in _opcode.c
seemed like a possible reason for the error:
oparg_int = (int)PyLong_AsLong(oparg);
from bytecode.
@serhiy-storchaka This 0xFFFFFFFF
...
from bytecode.
And I'm using Python 3.6.5 in Windows 10 x86_64.
from bytecode.
@MatthieuDartiailh Yes, you're right! (int)PyLong_AsLong(oparg)
causes this, but note that standard compiler could even compile 0xFFFFFFFFFF
..
I've found the way to solve this problem, a few minutes.
from bytecode.
I am not sure that specifying a whitelist for opcodes whose stack effect depends on its argument is a good approach. The list is not complete. It lacks following opcodes: BUILD_LIST
, BUILD_LIST_UNPACK
, BUILD_MAP_UNPACK
, BUILD_SET
, BUILD_SET_UNPACK
, BUILD_TUPLE
, BUILD_TUPLE_UNPACK
, BUILD_TUPLE_UNPACK_WITH_CALL
, CALL_FUNCTION_VAR
, CALL_FUNCTION_VAR_KW
, MAKE_CLOSURE
. Also in new Python versions new opcodes can be added, and the meaning of old opcodes can be changed.
Are there other opcodes that need a workaround besides LOAD_CONST
?
from bytecode.
#41 addresses this.
from bytecode.
Thanks for the ping @serhiy-storchaka . Actually I probably was in too much of a rush when reviewing the #43.
Looking through Python opcode and our implementation, I believe you are correct that only LOAD_CONST
can manipulate arbitrary objects. And limiting the workaround to this one seems safer. I will review your PR sometimes next week. I want in particular to understand the need for the modified tests.
Thanks again for catching this.
from bytecode.
I have extracted the fix for this issue into separate PR #44.
from bytecode.
Related Issues (20)
- The `Compare` enum is broken starting from Python 3.9
- Python 3.11 support HOT 5
- Is there any way to get the bytecode offsets along with the line number ? HOT 23
- treating `const_key` of a code object as mutable one HOT 4
- Flag inference is too agressive in determining generator HOT 1
- Using special optimization to get rid of recursion limitations when compiling really huge code HOT 1
- stack size calculation issue HOT 5
- Stack size with EXTENDED_ARG HOT 10
- Question: how stable is it to round-trip code? HOT 3
- Why are extended line offsets -127 and 126, and not -128 and 127? HOT 2
- Stack size computation issue HOT 2
- Creating functions through bytecode HOT 3
- Missing tag on 0.12.0 release HOT 1
- Update jump address handling for 3.10 HOT 1
- Bytecode doesn't properly set linenumbers (in corner case in Python 3.10rc1) HOT 2
- Errors in compute stacksize on 3.10 HOT 7
- Please clarify the copyright HOT 4
- Remove `Compare.EXC_MATCH` on Python>=3.9 HOT 1
- Update pre_and_post_stack_effect HOT 1
- Labels don't seem to be handled correctly with Python<3.9 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bytecode.