New submission from Andrei Kulakov <andrei....@gmail.com>:

[ins] In [63]: class A:pass

[ins] In [64]: import inspect

[ins] In [65]: inspect.getsource(A)

[snip]

/usr/local/Cellar/python@3.9/3.9.1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py
 in getfile(object)
    664             if getattr(module, '__file__', None):
    665                 return module.__file__
--> 666         raise TypeError('{!r} is a built-in class'.format(object))

The error is 'X is a built-in class', instead it should be OSError, source code 
is not available.

----------
messages: 397573
nosy: andrei.avk
priority: normal
severity: normal
status: open
title: Inspect.getsource raises wrong error on classes in interactive session
type: behavior
versions: Python 3.11

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44648>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to