Transcrypt icon indicating copy to clipboard operation
Transcrypt copied to clipboard

Reverse string slice goes into infinite loop fix

Open pjz opened this issue 6 years ago • 3 comments

I bumped into #455 in my own code, but a little investigation showed that a small patch to transcrypt/modules/org/transcrypt/__builtin__.js (viewable as the totality of PR #702) would fix it. I don't think the patch is outsized for the increase in functionality - negative steps in slices are fairly fundamental. I also don't understand why #455 was marked 'IS:limitation'.

pjz avatar Jan 21 '20 14:01 pjz

Thanks for the fix. I think this should be in the next major version. Still want to take a good long look at it. And indeed at least there should be a decent error report.

JdeH avatar Nov 02 '20 09:11 JdeH

Will be fixed in v3.9.4

JennaSys avatar Jul 14 '24 04:07 JennaSys

This fix (currently on dev_3.9.4 branch) required a bit more extra logic to cover edge cases, but I feel slicing is a foundational feature of Python and the extra code in the runtime is worth being able to move the behavior closer to that of CPython. I also added validations for invalid slices similar to CPython. The updated code shouldn't slow down slicing much for the more common step==1 use cases.

JennaSys avatar Jul 27 '24 23:07 JennaSys