Skip to content

'__import__' takes incorrect arguments crashing gpython #204

Open
@xiaxinmeng

Description

@xiaxinmeng

'import' takes incorrect arguments and it crashes gpython. we test the following code on Gopherjs
and Go/wasm online.

test.py

__import__( 'pkg', {}, {}, [''] )

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


Gpython 3.4.0 running in your browser with go/wasm
>>> __import__( 'pkg', {}, {}, [''] )
panic: interface conversion: py.Object is *py.List, not py.Tuple
goroutine 5 [running]:
github.com/go-python/gpython/py.BuiltinImport(0x0, 0x0, 0xc040420, 0x4, 0x4, 0x0, 0xc062db0, 0x0, 0x0, 0x0, ...)
    /home/ncw/go/src/github.com/go-python/gpython/py/import.go:394 +0x18
github.com/go-python/gpython/vm.callInternal(0x9d360, 0xc02ab80, 0xc040420, 0x4, 0x4, 0x0, 0xc0a40b0, 0x0, 0x0, 0x0, ...)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:1595 +0x25
github.com/go-python/gpython/vm.(*Vm).Call(0xc074540, 0x4, 0x0, 0x0, 0x0, 0x0, 0xc05ea60, 0xc040410)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:1689 +0x4e
github.com/go-python/gpython/vm.do_CALL_FUNCTION(0xc074540, 0x4, 0x0, 0x0)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:1428 +0x2
github.com/go-python/gpython/vm.RunFrame(0xc0a40b0, 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(0xc04c200, 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, 0xc04c200, 0x0, 0x0, 0x0, 0x0, 0x1, 0x9d240, 0xc04c200)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:2182 +0x2
github.com/go-python/gpython/repl.(*REPL).Run(0xc09a6c0, 0xc038330, 0x21)
    /home/ncw/go/src/github.com/go-python/gpython/repl/repl.go:99 +0x20
main.main.func1(0xc01e3f0, 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/)

>>> __import__( 'pkg', {}, {}, [''] )
[USER]: https://gpython.org/gpython.js: interface conversion: interface is *py.List, not py.Tuple
$callDeferred@https://gpython.org/gpython.js:4:22511
$panic@https://gpython.org/gpython.js:4:22957
$assertType@https://gpython.org/gpython.js:4:21361
EP@https://gpython.org/gpython.js:41:219420
DN@https://gpython.org/gpython.js:44:81763
EE.ptr.prototype.Call@https://gpython.org/gpython.js:44:87109
DC@https://gpython.org/gpython.js:44:77098
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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy