This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年12月29日 03:02 by danielsh, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| inspect-v1.diff | danielsh, 2012年12月29日 03:02 | review | ||
| inspect-v2.diff | danielsh, 2012年12月30日 03:04 | review | ||
| inspect-v3.diff | danielsh, 2012年12月31日 18:29 | review | ||
| inspect-v5.diff | danielsh, 2013年01月05日 04:13 | review | ||
| Messages (11) | |||
|---|---|---|---|
| msg178467 - (view) | Author: Daniel Shahaf (danielsh) | Date: 2012年12月29日 03:02 | |
Currently inspect.stack() returns a list of 6-tuples. I suggest to make it return a list of named tuples, so code that only needs one tuple element can get it by name. Current behaviour: % ./python -c 'import inspect; print(inspect.stack()[0])' (<frame object at 0x157fb38>, '<string>', 1, '<module>', None, None) Suggested behaviour: % ./python -c 'import inspect; print(inspect.stack()[0])' FrameInfo(frame=<frame object at 0xddab38>, filename='<string>', lineno=1, function='<module>', code_context=None, index=None) |
|||
| msg178478 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2012年12月29日 07:01 | |
+1 |
|||
| msg178485 - (view) | Author: Daniel Shahaf (danielsh) | Date: 2012年12月29日 12:44 | |
Why did you set stage to 'needs patch'? One is already attached. |
|||
| msg178549 - (view) | Author: Daniel Shahaf (danielsh) | Date: 2012年12月30日 03:04 | |
Add versionchanged per review. |
|||
| msg178709 - (view) | Author: Meador Inge (meador.inge) * (Python committer) | Date: 2012年12月31日 17:14 | |
This patch looks good to me with the exception that "versionchanged" should be 3.4. |
|||
| msg178713 - (view) | Author: Daniel Shahaf (danielsh) | Date: 2012年12月31日 18:29 | |
Fixed that in v3. |
|||
| msg179099 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2013年01月05日 01:33 | |
Should a test be added to or changed in test_inspect? Line 163 has a test_stack method that calls inspect.stack. |
|||
| msg179100 - (view) | Author: Meador Inge (meador.inge) * (Python committer) | Date: 2013年01月05日 02:18 | |
I suppose asserting the type wouldn't hurt, but I don't consider it that important: --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -164,12 +164,16 @@ class TestInterpreterStack(IsTestBase): self.assertTrue(len(mod.st) >= 5) self.assertEqual(revise(*mod.st[0][1:]), (modfile, 16, 'eggs', [' st = inspect.stack()\n'], 0)) + self.assertIsInstance(mod.st[0], inspect.FrameInfo) self.assertEqual(revise(*mod.st[1][1:]), (modfile, 9, 'spam', [' eggs(b + d, c + f)\n'], 0)) + self.assertIsInstance(mod.st[1], inspect.FrameInfo) self.assertEqual(revise(*mod.st[2][1:]), (modfile, 43, 'argue', [' spam(a, b, c)\n'], 0)) + self.assertIsInstance(mod.st[2], inspect.FrameInfo) self.assertEqual(revise(*mod.st[3][1:]), (modfile, 39, 'abuse', [' self.argue(a, b, c)\n'], 0)) + self.assertIsInstance(mod.st[3], inspect.FrameInfo) TestGetClosureVars builds the named tuples directly and compares them. For example: expected = inspect.ClosureVars(nonlocal_vars, global_vars, builtin_vars, unbound_names) self.assertEqual(inspect.getclosurevars(f(_arg)), expected) Doing this for FrameInfo is awkward because we don't have a frame object to construct the named tuple with. |
|||
| msg179106 - (view) | Author: Daniel Shahaf (danielsh) | Date: 2013年01月05日 04:10 | |
Terry J. Reedy wrote on Sat, Jan 05, 2013 at 01:33:50 +0000: > Should a test be added to or changed in test_inspect? Line 163 has > a test_stack method that calls inspect.stack. Makes sense; added a test that tests named attribute access. Thanks for the pointer. |
|||
| msg225823 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2014年08月24日 14:54 | |
New changeset d03730abd2f6 by Antoine Pitrou in branch 'default': Issue #16808: inspect.stack() now returns a named tuple instead of a tuple. http://hg.python.org/cpython/rev/d03730abd2f6 |
|||
| msg225824 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2014年08月24日 14:55 | |
It seems like this patch had been overlooked. I refreshed it for 3.5, added a couple tests, and pushed it. Thank you, Daniel! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:39 | admin | set | github: 61012 |
| 2014年08月24日 14:55:31 | pitrou | set | status: open -> closed assignee: meador.inge -> nosy: + pitrou messages: + msg225824 resolution: fixed stage: commit review -> resolved |
| 2014年08月24日 14:54:33 | python-dev | set | nosy:
+ python-dev messages: + msg225823 |
| 2014年08月22日 21:13:16 | davet | set | nosy:
+ davet |
| 2014年01月29日 06:43:54 | Claudiu.Popa | set | nosy:
+ Claudiu.Popa |
| 2014年01月28日 23:36:17 | yselivanov | set | nosy:
+ yselivanov |
| 2014年01月28日 23:36:11 | yselivanov | set | versions: + Python 3.5, - Python 3.4 |
| 2013年01月05日 04:13:49 | danielsh | set | files: + inspect-v5.diff |
| 2013年01月05日 04:13:09 | danielsh | set | files: - inspect-v4.diff |
| 2013年01月05日 04:10:05 | danielsh | set | files:
+ inspect-v4.diff messages: + msg179106 |
| 2013年01月05日 02:18:44 | meador.inge | set | messages: + msg179100 |
| 2013年01月05日 01:33:50 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg179099 |
| 2012年12月31日 18:29:22 | danielsh | set | files:
+ inspect-v3.diff messages: + msg178713 |
| 2012年12月31日 17:14:07 | meador.inge | set | nosy:
+ meador.inge messages: + msg178709 assignee: meador.inge stage: needs patch -> commit review |
| 2012年12月30日 03:04:15 | danielsh | set | files:
+ inspect-v2.diff keywords: + patch messages: + msg178549 |
| 2012年12月29日 12:44:41 | danielsh | set | messages: + msg178485 |
| 2012年12月29日 07:01:36 | rhettinger | set | nosy:
+ rhettinger messages: + msg178478 keywords: + easy, - patch type: enhancement stage: needs patch |
| 2012年12月29日 03:02:29 | danielsh | create | |