New submission from Thomas Viehmann <[email protected]>:
getting a class source regresses in Python 3.9 onwards.
The following worked in Python 3.8, now it doesn't anymore for 3.9.1 and
3.10.0a2:
(save as foo.py)
import inspect
class Foo:
def spam(self):
global Bar
class Bar:
pass
print(inspect.getsource(Bar))
Foo().spam()
It seems that getsource is very brittle for classes.
----------
components: Library (Lib)
messages: 383223
nosy: t-vi
priority: normal
severity: normal
status: open
title: getting a class source regresses in Python 3.9
type: behavior
versions: Python 3.10, Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42666>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com