pikasTech / PikaPython

An ultra-lightweight Python interpreter that runs with only 4KB of RAM, zero dependencies. It is ready to use out of the box without any configuration required and easy to extend with C. Similar project: MicroPython, JerryScript.
http://pikapython.com/
MIT License
1.45k stars 132 forks source link

dict.items() set/list/tuple value segmentation fault & reverse items loop #322

Open z64rankaisija opened 1 year ago

z64rankaisija commented 1 year ago

I'm not entirely sure on Python 3 version differences so I'm not entirely sure if these are considered issues for PikaPython. But I'm creating this issue just in case if these are considered issues.

I tested this code and it results in segmentation fault. It does not matter if it's using (), {} or [], all of them seg fault.

dict = {
    'a': {1, 2, 3},
    'b': {4, 5, 6},
    'c': {7, 8, 9},
}

for k, (a, b, c) in dict.items():
    print(k, ':', a, b, c)

Another thing that was unexpected to me was this going through the dictionary in reverse.

dict = {
    'a': 1,
    'b': 4,
    'c': 7,
}

for k, a in dict.items():
    print(k, ':', a)

Output:

c : 7
b : 4
a : 1
pikasTech commented 1 year ago

Thank you for bringing these issues to our attention.

I regret to inform you that the current version of PikaPython does not support some of the features you've tried to use:

We recognize the importance of these features and our development team is actively working to incorporate them into future versions of PikaPython. For the time being, we suggest that you maintain this issue open. Once these features are integrated, I will personally update you in this thread.

In the interim, I recommend simplifying your code. For instance, when iterating over dictionary items, you could use a single variable like so: . Moreover, I suggest avoiding the use of sets and dependence on dictionary order to prevent any unpredictable behavior.for x, y in ...: a,b,c=y

Thank you for your understanding and patience. We truly value your feedback as it helps us improve our platform and better serve our users. Please don't hesitate to reach out if you have any further concerns or queries.

pikasTech commented 10 months ago

fixed the reverse of dictionary iter. image

https://github.com/pikasTech/PikaPython/commit/ca2820efb627b2bcb09eeddadb3e3b8e091e7fb0