Skip to content

Comparing uncomparable types in 'is' crashes gpython #205

Open
@xiaxinmeng

Description

@xiaxinmeng

In the following program, we compare two tuples with "is", while tuple types are uncomparable crashing gpython. We test it on the online gpython GO/wasm and Gopherjs.

test.py


e = (1, 2)
f = (1, 2)
print(e is f)

Output on GO/wasm(https://gpython.org/?wasm):


Gpython 3.4.0 running in your browser with go/wasm
>>> e = (1, 2)
>>> f = (1, 2)
>>> e is e
panic: runtime error: comparing uncomparable type py.Tuple
goroutine 5 [running]:
github.com/go-python/gpython/vm.do_COMPARE_OP(0xc0749a0, 0x8, 0x0, 0x0)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:1051 +0x67
github.com/go-python/gpython/vm.RunFrame(0xc0e0630, 0x0, 0xc07bd18, 0x0, 0x0)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:1785 +0x3f
github.com/go-python/gpython/vm.EvalCodeEx(0xc04c600, 0xc062db0, 0xc062db0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:2162 +0xa3
github.com/go-python/gpython/vm.Run(0xc062db0, 0xc062db0, 0xc04c600, 0x0, 0x0, 0x0, 0x0, 0x1, 0x9d240, 0xc04c600)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:2182 +0x2
github.com/go-python/gpython/repl.(*REPL).Run(0xc09a6c0, 0xc01e740, 0x6)
    /home/ncw/go/src/github.com/go-python/gpython/repl/repl.go:99 +0x20
main.main.func1(0xc01e730, 0x2, 0x2)
    /home/ncw/go/src/github.com/go-python/gpython/repl/web/main.go:82 +0x4
syscall/js.callbackLoop()
    /opt/go/go1.11/src/syscall/js/callback.go:116 +0x7
created by syscall/js.NewCallback.func1
    /opt/go/go1.11/src/syscall/js/callback.go:40 +0x2
...

Output on Gopherjs (https://gpython.org/)


Gpython 3.4.0 running in your browser with gopherjs
>>> e = (1, 2)
>>> f = (1, 2)
>>> e is e
[USER]: https://gpython.org/gpython.js: runtime error: comparing uncomparable type py.Tuple
$callDeferred@https://gpython.org/gpython.js:4:22511
$panic@https://gpython.org/gpython.js:4:22957
AK@https://gpython.org/gpython.js:10:2429
$interfaceIsEqual@https://gpython.org/gpython.js:4:6214
CC@https://gpython.org/gpython.js:44:59553
DO@https://gpython.org/gpython.js:44:91592
DU@https://gpython.org/gpython.js:44:107450
DW@https://gpython.org/gpython.js:44:109015
G.ptr.prototype.Run@https://gpython.org/gpython.js:56:3575
$b@https://gpython.org/gpython.js:60:3908
$b@https://gpython.org/gpython.js:59:2625
r@https://gpython.org/gpython.js:4:23443
$runScheduled@https://gpython.org/gpython.js:4:24007
$schedule@https://gpython.org/gpython.js:4:24184
$go@https://gpython.org/gpython.js:4:23907
I/$packages["github.com/gopherjs/gopherwasm/js"]<@https://gpython.org/gpython.js:59:2240
$externalizeFunction/e.$externalizeWrapper@https://gpython.org/gpython.js:4:28925
a@https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/1.23.2/js/jquery.terminal.min.js:40:82615
k@https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/1.23.2/js/jquery.terminal.min.js:40:83463
ENTER@https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/1.23.2/js/jquery.terminal.min.js:40:14915
$e@https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/1.23.2/js/jquery.terminal.min.js:40:28362
dispatch@https://code.jquery.com/jquery-latest.js:4641:9
add/elemData.handle@https://code.jquery.com/jquery-latest.js:4309:28
...


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions