[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2020-11-29 Thread Alexey Volkov
Alexey Volkov added the comment: This is also an issue even for non-interactive scenarios: When doing `python -c ''` inspect.getsource does not work and there are no stack traces. Perhaps this case will be easier to fix? -- nosy: +Ark-kun ___

[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2018-12-11 Thread Terry J. Reedy
Terry J. Reedy added the comment: Do we really need to say that getsource(object) can only get the object's source if it is accessible from the object? Getsource also fails if a module is loaded from a .pyc with not corresponding .py available. The problem is not the call being in

[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2018-10-29 Thread Ivan Pozdeev
Ivan Pozdeev added the comment: See https://bugs.python.org/issue33826?@ok_message=msg%20328824%20created%0Aissue%2033826%20message_count%2C%20messages%20edited%20ok&@template=item#msg319692 how IPython stores source from interactive input and why it's not appropriate for vanilla REPL IMO.

[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2017-07-05 Thread R. David Murray
R. David Murray added the comment: Probably. Figure out a protocol to inject them into linecache, perhaps. But I'm not sure such a thing would be accepted. If you can figure out a way to make it work at least theoretically, it would probably be best to talk about it on python-ideas first.

[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2017-07-05 Thread Vitor Pereira
Vitor Pereira added the comment: So, what would be the right approach here? Store the interactive session's input text in memory? -- nosy: +vmsp ___ Python tracker

[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2016-05-18 Thread Steven Barker
Steven Barker added the comment: The problem being discussed here just came up on Stack Overflow today: http://stackoverflow.com/questions/37288135/inspect-module-for-python/ The cause of the incorrect error message is pretty clear. The relevant code from `inspect.getfile` should do something

[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2015-10-12 Thread nikitakit
nikitakit added the comment: I just ran into this issue trying to introspect an IPython session, in which case the __main__ module doesn't have a file associated with it. But it turns out that methods defined in a class do have source code associated with them, so it's possible to add a

[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2015-06-24 Thread Zorceta
Zorceta added the comment: When provided object is not from a file should be 'When `inspect` can't find the source file of provided object'. My mistake. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12920

[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2015-06-23 Thread Zorceta
Changes by Zorceta zorc...@gmail.com: -- nosy: -docs@python ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12920 ___ ___ Python-bugs-list mailing

[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2015-06-23 Thread Zorceta
Changes by Zorceta zorc...@gmail.com: -- components: +IDLE, Interpreter Core -Documentation ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12920 ___

[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2015-06-23 Thread Zorceta
Zorceta added the comment: When provided object is not from a file, like input in interactive shell, `inspect` internals will check for it in `linecache`, which official Python shell and IDLE won't put interactive shell input into, yet. This can be simply solved. Whether interactive shell