go-python / gpython

gpython is a python interpreter written in go "batteries not included"
BSD 3-Clause "New" or "Revised" License
879 stars 94 forks source link

set(range(100)) behaves different with CPython and crashes gpython #142

Closed xiaxinmeng closed 2 years ago

xiaxinmeng commented 2 years ago

CPython can well handle the following program test.py, while gpython cannot transform it automatically.

test.py ''' s = set(range(100)) '''

Crashing Information: gpython test.py ''' panic: interface conversion: py.Object is *py.Range, not py.Tuple

goroutine 1 [running]: github.com/go-python/gpython/py.SetNew(0xc0000d50e0, 0xc0000dceb0, 0x1, 0x2, 0x0, 0x6abfc0, 0xc0000cc680, 0xc0000f7610, 0x40bc6d) /home/ncw/go/src/github.com/go-python/gpython/py/set.go:63 +0x20d ..... main.main() /home/ncw/go/src/github.com/go-python/gpython/main.go:113 +0x7ff '''

version: Gpython 3.4.0 on Ubuntu 16.04

raff commented 2 years ago

This works fine on MacOS with gpython from master branch and it also work on Ubuntu 20.04, even if the result is different than CPython (in CPython the set is sorted, in gpython the order changes every time I print, probably an issue of sets being implemented as a map)

sbinet commented 2 years ago

strictly speaking, I don't see why set output should be sorted. according to:

sbinet commented 2 years ago

tentatively closing this as invalid (I also couldn't reproduce on master)