
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2005-06-10 13:49 bysonderblade, last changed2022-04-11 14:56 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| inspect.py.diff | gpolo,2008-02-07 19:42 | review | ||
| test_inspect-trunk.diff | ajaksu2,2009-04-25 19:38 | Test source reloading with inspect.getsource | review | |
| test_inspect-py3k2.diff | ajaksu2,2009-04-25 20:08 | Test source reloading with inspect.getsource in py3k | review | |
| issue1218234.diff | berker.peksag,2012-12-10 08:00 | review | ||
| Messages (16) | |||
|---|---|---|---|
| msg60756 -(view) | Author: Björn Lindqvist (sonderblade) | Date: 2005-06-10 13:49 | |
This is test.py:def foo(): print "Bla"And in an interactive session:>>> import inspect, test>>> test.foo()Bla>>> inspect.getsource(test.foo)'def foo():\n print "Bla"\n'Now I edit test.py to (without exiting the interactivesession):def foo(): print "Oh no!">>> reload(test)<module 'test' from 'test.py'>>>> test.foo()Oh no!>>> inspect.getsource(test.foo)'def foo():\n print "Bla"\n'inspect should output the new source. | |||
| msg60757 -(view) | Author: Georg Brandl (georg.brandl)*![]() | Date: 2005-06-10 16:36 | |
Logged In: YES user_id=1188172This is the fault of the linecache module which inspectuses. It caches the file contents and does not reload itaccordingly. However, I assume it's pretty hard finding agood solution to this. | |||
| msg62174 -(view) | Author: Guilherme Polo (gpolo)*![]() | Date: 2008-02-07 19:42 | |
I'm attaching a patch. Is there some hidden problem that it may cause ?By the way, this issue is a duplicate ofhttp://bugs.python.org/issue993580 | |||
| msg86540 -(view) | Author: Daniel Diniz (ajaksu2)*![]() | Date: 2009-04-25 19:38 | |
Fix was committed to py3k but with no tests AFAIK. Here's a (failing)test for trunk that runs OK after Guilherme's patch.We might want to keep this behavior restricted for when the module wasreloaded. | |||
| msg86544 -(view) | Author: Daniel Diniz (ajaksu2)*![]() | Date: 2009-04-25 20:08 | |
Er, no, it wasn't committed to py3k, it was just me getting my patchesmixed. Attaching the py3k test with relative import fixed. | |||
| msg110435 -(view) | Author: Mark Lawrence (BreamoreBoy)* | Date: 2010-07-16 13:23 | |
The change to inspect.py is two lines. Given that unit test patches are also supplied could someone with the knowledge give yes or no to accepting this patch? | |||
| msg110436 -(view) | Author: Jean-Paul Calderone (exarkun)*![]() | Date: 2010-07-16 13:27 | |
Calling linecache.checkcache for every inspect.getsource call sounds like a fairly bad idea to me.linecache.checkcache does a stat() of every single cached file. | |||
| msg110438 -(view) | Author: Jean-Paul Calderone (exarkun)*![]() | Date: 2010-07-16 13:31 | |
> linecache.checkcache does a stat() of every single cached file.Ah, sorry. I didn't read carefully enough. I see that the patch passes in the filename and checkcache restricts the work it does in that case.Something else to consider, though, is that this change means you'll also get the new source if you *don't* reload the module, too. So, what exactly is inspect.getsource() supposed to be doing? Giving you the current on-disk contents of the relevant source file? Or giving you the actual source corresponding to the object passed to it?If the latter, then this actually needs to be more tightly integrated with module reloading somehow. | |||
| msg217951 -(view) | Author: Jason R. Coombs (jaraco)*![]() | Date: 2014-05-05 20:18 | |
This issue appears implicated inhttps://bitbucket.org/pypa/setuptools/issue/201 | |||
| msg217990 -(view) | Author: Yury Selivanov (yselivanov)*![]() | Date: 2014-05-06 15:33 | |
Thanks, I'll take a look at the patch. | |||
| msg217991 -(view) | Author: R. David Murray (r.david.murray)*![]() | Date: 2014-05-06 15:57 | |
Note that there has never been a strict correspondence between linecache/getsource, the module in memory, and the code on disk. If the file is changed before a traceback is generated, for example, you will get the new source. That doesn't mean fixing the reload case is wrong, it's just something to keep in mind. | |||
| msg232328 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2014-12-08 21:06 | |
New changeset8e2505d535c8 by Yury Selivanov in branch 'default':inspect: Fix getsource() to load updated source of reloaded modulehttps://hg.python.org/cpython/rev/8e2505d535c8 | |||
| msg232329 -(view) | Author: Yury Selivanov (yselivanov)*![]() | Date: 2014-12-08 21:07 | |
Fixed in 3.5. Not sure if we need to backport this to 3.4 and 2.7.Closing this issue. Thanks to Björn Lindqvist and Berker Peksag! | |||
| msg232332 -(view) | Author: Jason R. Coombs (jaraco)*![]() | Date: 2014-12-08 21:48 | |
FWIW, I'd appreciate a backport to 3.4, given that 3.5 is scheduled for release in Sep 2015. | |||
| msg232335 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2014-12-08 23:01 | |
New changesete52d8e888df1 by Yury Selivanov in branch '3.4':inspect: Fix getsource() to load updated source of reloaded modulehttps://hg.python.org/cpython/rev/e52d8e888df1 | |||
| msg232336 -(view) | Author: Yury Selivanov (yselivanov)*![]() | Date: 2014-12-08 23:10 | |
@Jason: done ;) | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:11 | admin | set | github: 42071 |
| 2014-12-08 23:10:15 | yselivanov | set | messages: +msg232336 |
| 2014-12-08 23:01:53 | python-dev | set | messages: +msg232335 |
| 2014-12-08 22:24:35 | berker.peksag | set | stage: patch review -> resolved |
| 2014-12-08 21:48:50 | jaraco | set | messages: +msg232332 |
| 2014-12-08 21:07:36 | yselivanov | set | status: open -> closed resolution: fixed |
| 2014-12-08 21:07:29 | yselivanov | set | messages: +msg232329 |
| 2014-12-08 21:06:18 | python-dev | set | nosy: +python-dev messages: +msg232328 |
| 2014-05-06 15:57:13 | r.david.murray | set | nosy: +r.david.murray messages: +msg217991 |
| 2014-05-06 15:33:58 | yselivanov | set | messages: +msg217990 |
| 2014-05-06 05:54:48 | berker.peksag | set | nosy: +yselivanov versions: + Python 3.5, - Python 3.2, Python 3.3 |
| 2014-05-05 23:41:59 | exarkun | set | nosy: -exarkun |
| 2014-05-05 20:18:07 | jaraco | set | nosy: +jaraco messages: +msg217951 |
| 2014-02-03 19:05:36 | BreamoreBoy | set | nosy: -BreamoreBoy |
| 2012-12-10 08:01:48 | berker.peksag | set | nosy: +berker.peksag |
| 2012-12-10 08:00:46 | berker.peksag | set | files: +issue1218234.diff versions: + Python 3.3, Python 3.4, - Python 3.1 |
| 2010-07-16 13:31:59 | exarkun | set | messages: +msg110438 |
| 2010-07-16 13:27:42 | exarkun | set | nosy: +exarkun messages: +msg110436 |
| 2010-07-16 13:23:06 | BreamoreBoy | set | nosy: +BreamoreBoy messages: +msg110435 versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6, Python 3.0 |
| 2009-04-25 20:08:18 | ajaksu2 | set | files: -test_inspect-py3k.diff |
| 2009-04-25 20:08:09 | ajaksu2 | set | files: +test_inspect-py3k2.diff messages: +msg86544 |
| 2009-04-25 19:39:15 | ajaksu2 | set | files: +test_inspect-py3k.diff |
| 2009-04-25 19:38:32 | ajaksu2 | set | files: +test_inspect-trunk.diff type: behavior versions: + Python 2.6, Python 3.0, - Python 2.5 keywords: +patch nosy: +ajaksu2 messages: +msg86540 stage: patch review |
| 2009-04-05 18:16:38 | georg.brandl | link | issue993580 superseder |
| 2009-04-05 18:16:38 | georg.brandl | unlink | issue993580 dependencies |
| 2009-03-04 15:13:21 | ajaksu2 | link | issue993580 dependencies |
| 2008-02-07 19:42:24 | gpolo | set | files: +inspect.py.diff nosy: +gpolo messages: +msg62174 |
| 2005-06-10 13:49:10 | sonderblade | create | |