go-python / go-python/gpython

Reassignment of 'getattr' leads to gpython crashing

Open
#202 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
1k
Forks
105
PR merge metrics
No merged PRs in 30d

Description

Reassigning __getattr__ with getattr in a class and then using the attribute 'spam' triggers gpython crashing. See the following example. We test the example on the online gpython i.e., GO/wasm and Gopherjs. GO/wasm can well handle the test while it crashes on the Gopherjs.

test.py
```

class c(object):
__getattr__ = getattr
c().spam

```

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

```
Gpython 3.4.0 running in your browser with gopherjs
>>> class c(object):
...     __getattr__ = getattr
... 
>>> c().spam
[USER]: https://gpython.org/gpython.js: too much recursion
$assertType@https://gpython.org/gpython.js:4:20889
GL.ptr.prototype.Call@https://gpython.org/gpython.js:41:291927
GL.ptr.prototype.M__call__@https://gpython.org/gpython.js:41:301617
FK@https://gpython.org/gpython.js:41:255589
MH.ptr.prototype.CallMethod@https://gpython.org/gpython.js:41:369579
MP@https://gpython.org/gpython.js:41:370268
MR@https://gpython.org/gpython.js:41:371135
FO@https://gpython.org/gpython.js:41:262478
FP@https://gpython.org/gpython.js:41:264051
P@https://gpython.org/gpython.js:54:33516
GL.ptr.prototype.Call@https://gpython.org/gpython.js:41:292125
GL.ptr.prototype.M__call__@https://gpython.org/gpython.js:41:301617
FK@https://gpython.org/gpython.js:41:255589
MH.ptr.prototype.CallMethod@https://gpython.org/gpython.js:41:369579
MP@https://gpython.org/gpython.js:41:370268
MR@https://gpython.org/gpython.js:41:371135
FO@https://gpython.org/gpython.js:41:262478
FP@https://gpython.org/gpython.js:41:264051
P@https://gpython.org/gpython.js:54:33516
GL.ptr.prototype.Call@https://gpython.org/gpython.js:41:292125
GL.ptr.prototype.M__call__@https://gpython.org/gpython.js:41:301617
FK@https://gpython.org/gpython.js:41:255589
MH.ptr.prototype.CallMethod@https://gpython.org/gpython.js:41:369579
MP@https://gpython.org/gpython.js:41:370268
MR@https://gpython.org/gpython.js:41:371135
FO@https://gpython.org/gpython.js:41:262478
...

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.