[pypy-issue] Issue #3109: Inheriting from a function produces nonsensical-ish error message (pypy/pypy)

Julian Berman issues-reply at bitbucket.org
Wed Oct 30 19:04:58 EDT 2019


New issue 3109: Inheriting from a function produces nonsensical-ish error message
https://bitbucket.org/pypy/pypy/issues/3109/inheriting-from-a-function-produces

Julian Berman:

```
>>> def foo():
...     pass

>>>
>>> class Bar(foo):
...     pass
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'internal-code' object expected, got 'str' instead

'internal-code' object expected, got 'str' instead
```

\(CPython is no better, FWIW, on 3.7:

‌

```
>>> def foo():
...     pass
...
>>>
>>> class Bar(foo):
...     pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: function() argument 1 must be code, not str
```

\)

‌

Something like “superclasses of a class must be instances of `type` \(i.e. classes\)” would be a lot nicer \(if in fact that is the criteria, I forget\)




More information about the pypy-issue mailing list