gh-83035: handle decorator with nested parens in inspect.getsource#99654
gh-83035: handle decorator with nested parens in inspect.getsource#99654JelleZijlstra merged 4 commits intopython:mainfrom
Conversation
Summary: Backport python/cpython#99654 to fix `inspect.getsource` handling of decorator calls with nested parens. Reviewed By: itamaro Differential Revision: D41438553 fbshipit-source-id: 420a90d
|
I think there's a simpler solution: remove the special cases for parentheses completely. That code is unnecessary because we don't emit NEWLINE tokens for newlines within parentheses. Instead we emit NL: If the parens-handling code was necessary, we would see a similar bug with |
Good call! I wondered about that, but decided to just stick with the less-invasive fix. Thanks for the nudge, I'll try just removing the paren-handling instead. |
* main: (112 commits) pythongh-99894: Ensure the local names don't collide with the test file in traceback suggestion error checking (python#99895) pythongh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data (pythonGH-99613) Doc: Add summary line to isolation_level & autocommit sqlite3.connect params (python#99917) pythonGH-98906 ```re``` module: ```search() vs. match()``` section should mention ```fullmatch()``` (pythonGH-98916) pythongh-89189: More compact range iterator (pythonGH-27986) bpo-47220: Document the optional callback parameter of weakref.WeakMethod (pythonGH-25491) pythonGH-99905: Fix output of misses in summarize_stats.py execution counts (pythonGH-99906) pythongh-99845: PEP 670: Convert PyObject macros to functions (python#99850) pythongh-99845: Use size_t type in __sizeof__() methods (python#99846) pythonGH-99877) Fix typo in exception message in `multiprocessing.pool` (python#99900) pythongh-87092: move all localsplus preparation into separate function called from assembler stage (pythonGH-99869) pythongh-99891: Fix infinite recursion in the tokenizer when showing warnings (pythonGH-99893) pythongh-99824: Document that sqlite3.connect implicitly open a transaction if autocommit=False (python#99825) pythonGH-81057: remove static state from suggestions.c (python#99411) Improve zip64 limit error message (python#95892) pythongh-98253: Break potential reference cycles in external code worsened by typing.py lru_cache (python#98591) pythongh-99127: Allow some features of syslog to the main interpreter only (pythongh-99128) pythongh-82836: fix private network check (python#97733) Docs: improve accuracy of socketserver reference (python#24767) ...
|
Updated. I also wondered looking at this code whether we couldn't just use the AST lineno information for all objects (as is already done for classes, since #35113) and eliminate the need for |
JelleZijlstra
left a comment
There was a problem hiding this comment.
Thanks, looks good!
I feel this should be safe to backport to the bugfix branches, do you agree?
|
@JelleZijlstra Yes, I think this should be safe to backport. |
|
Thanks @carljm for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
|
Sorry @carljm and @JelleZijlstra, I had trouble checking out the |
…rce (pythonGH-99654) (cherry picked from commit 68e4129) Co-authored-by: Carl Meyer <[email protected]>
|
GH-100080 is a backport of this pull request to the 3.10 branch. |
|
Thanks @carljm for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
…rce (pythonGH-99654) (cherry picked from commit 68e4129) Co-authored-by: Carl Meyer <[email protected]>
|
GH-100081 is a backport of this pull request to the 3.11 branch. |
|
Thanks @carljm for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
…rce (pythonGH-99654) (cherry picked from commit 68e4129) Co-authored-by: Carl Meyer <[email protected]>
|
oops now we'll have two backports |
No, she force-pushes to the existing backport branch if this happens (idk if it's an undocumented feature or a bug, it's a bit strange) |
…H-99654) (cherry picked from commit 68e4129) Co-authored-by: Carl Meyer <[email protected]>
…H-99654) (cherry picked from commit 68e4129) Co-authored-by: Carl Meyer <[email protected]>
…source (#99654) Summary: Backport the upstream fix from python/cpython#99654 Reviewed By: carljm Differential Revision: D41824891 fbshipit-source-id: 903f676
Uh oh!
There was an error while loading. Please reload this page.