Thomas Viehmann added the comment:
I might add that this is a case I hit in the PyTorch test suite.
I tried to fix this a long time ago in a pricipled way in
https://bugs.python.org/issue33826
and Guido explained that fixing it was too heavy handed to be worthwile in
https://mail.python.org
New submission from Thomas Viehmann :
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
clas
Change by Thomas Viehmann :
--
nosy: -t-vi
resolution: -> rejected
___
Python tracker
<https://bugs.python.org/issue33826>
___
___
Python-bugs-list mai
Change by Thomas Viehmann :
--
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue33826>
___
___
Pyth
Thomas Viehmann added the comment:
Note that the module is less granular than the filename in IPython - i.e. it's
useless for within notebooks.
--
nosy: +t-vi
___
Python tracker
<https://bugs.python.org/is
Change by Thomas Viehmann :
--
pull_requests: +13770
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/13894
___
Python tracker
<https://bugs.python.org/issu
Change by Thomas Viehmann :
--
pull_requests: +13768
pull_request: https://github.com/python/cpython/pull/13894
___
Python tracker
<https://bugs.python.org/issue37
Change by Thomas Viehmann :
--
resolution: duplicate ->
___
Python tracker
<https://bugs.python.org/issue33826>
___
___
Python-bugs-list mailing list
Un
Change by Thomas Viehmann :
--
nosy: -t-vi
___
Python tracker
<https://bugs.python.org/issue33826>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Thomas Viehmann :
--
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue33826>
___
___
Python-bugs-list
Thomas Viehmann added the comment:
Yeah, it's a shame no-one looked at the patch that seems to fix the underlying
cause and now it's just a duplicate of a bug to improve error messages.
On the up side, closing this bug will stop me from getting reminders about it.
--
Thomas Viehmann added the comment:
So I want "inspect.showsource" to have the same output whether my class has
been defined in a .py or in my Jupyter notebook.
I appreciate there are limitations to what "inspect.showsource" can do, but I
am not so sure how that cr
Thomas Viehmann added the comment:
Apologies for not being clear.
So I wrote:
In IPython (or Jupyter), `inspect.getsource` is able to retrieve the source
code for functions but not classes.
By this I mean:
import inspect
class X:
pass
inspect.getsource(X)
Note that:
- it won't wo
New submission from Thomas Viehmann :
Hello,
thank you for Python!
In IPython (or Jupyter), `inspect.getsource` is able to retrieve the source
code for functions but not classes.
The fundamental reason is that for functions, a "filename" (input reference
rather) is available via f
14 matches
Mail list logo