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.

classification
Title: New Node may not be visited in lib2to3.refactor.RefactoringTool.traverse_by
Type: behavior Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: chrome, gregory.p.smith
Priority: normal Keywords: patch

Created on 2020-08-28 13:32 by chrome, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
example.py chrome, 2020-08-29 02:58
Pull Requests
URL Status Linked Edit
PR 21988 closed chrome, 2020-08-28 13:37
Messages (4)
msg376035 - (view) Author: Chrome (chrome) * Date: 2020-08-28 13:32
`lib2to3.refactor.RefactoringTool.traverse_by` do a pre-order or post-order, and apply every candidate fixer to each node when traverse the tree. when a prior fixer add a new node that contains children, these children won't be visited by posterior fixers.
msg376036 - (view) Author: Chrome (chrome) * Date: 2020-08-28 13:33
`lib2to3.refactor.RefactoringTool.traverse_by` do a pre-order or post-order traverse algorithm, and apply every candidate fixer to each node when traverse the tree. when a prior fixer add a new node that contains children, these children won't be visited by posterior fixers.
msg376055 - (view) Author: Chrome (chrome) * Date: 2020-08-29 02:58
you can run example.py to reproduce this bug.
msg381534 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2020-11-21 09:19
I expect your overall logic is sound in the PR. But this is a public API change, and while we've typically exempted lib2to3 from needing to concern itself about deprecations and API changes by leaving it undocumented and explicitly promising not to care about this module in that sense... Enough things use it today that we should probably not do that anymore.

Especially given that we're considering it a deprecated library these days. It isn't likely to stand up well to 3.10+'s new grammar.

Various projects have forked lib2to3 into their own maintained thing either directly on PyPI or as an internalized third_party fork within their own project (as I believe Black has done?). It is probably best to do that for changes of this nature rather than push for them to be included in a future stdlib lib2to3.

See https://bugs.python.org/issue40360 for context.
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 85821
2020-11-21 09:20:17gregory.p.smithsetstatus: open -> closed
resolution: wont fix
stage: patch review -> resolved
2020-11-21 09:19:57gregory.p.smithsetnosy: + gregory.p.smith
messages: + msg381534
2020-08-29 02:58:14chromesetfiles: + example.py

messages: + msg376055
2020-08-29 01:02:00chromesetversions: + Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9
2020-08-28 13:48:16chromesettitle: new Node may not visited in lib2to3.refactor.RefactoringTool.traverse_by -> New Node may not be visited in lib2to3.refactor.RefactoringTool.traverse_by
2020-08-28 13:37:36chromesetkeywords: + patch
stage: patch review
pull_requests: + pull_request21097
2020-08-28 13:33:20chromesetmessages: + msg376036
2020-08-28 13:32:14chromecreate