Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call not visited in ast.NodeTransformer #90875

Closed
davidcastells mannequin opened this issue Feb 11, 2022 · 4 comments
Closed

Call not visited in ast.NodeTransformer #90875

davidcastells mannequin opened this issue Feb 11, 2022 · 4 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@davidcastells
Copy link
Mannequin

davidcastells mannequin commented Feb 11, 2022

BPO 46719
Nosy @isidentical, @davidcastells

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2022-02-11.13:29:14.687>
labels = ['type-bug', '3.8', '3.9', '3.10', '3.7', 'library']
title = 'Call not visited in ast.NodeTransformer'
updated_at = <Date 2022-02-11.13:40:39.177>
user = 'https://github.com/davidcastells'

bugs.python.org fields:

activity = <Date 2022-02-11.13:40:39.177>
actor = 'BTaskaya'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2022-02-11.13:29:14.687>
creator = 'davidcastells'
dependencies = []
files = []
hgrepos = []
issue_num = 46719
keywords = []
message_count = 2.0
messages = ['413069', '413070']
nosy_count = 2.0
nosy_names = ['BTaskaya', 'davidcastells']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue46719'
versions = ['Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']

@davidcastells
Copy link
Mannequin Author

davidcastells mannequin commented Feb 11, 2022

If I create a class derived from ast.NodeTransformer and implement the visit_Call.
When run on the below code, the visit_Call function is only called once (for the print function, and not for ord). It looks like calls in function arguments are ignored.

def main():
    print(ord('A'))

On the other hand, on the following code it correctly visits both functions (print and ord).

def main():
    c = org('A')
    print(c)

@davidcastells davidcastells mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 11, 2022
@isidentical
Copy link
Sponsor Member

It looks like calls in function arguments are ignored.

Please share a small, self-contained reproducer.

From what I can assume by this message, the problem is that you are not calling self.generic_visit(node) on the first call you are handling. If you don't call visit/generic_visit on the rood node that you are handling (print(ord('A')), then it will never visit ord('A') in a standalone fashion.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@hauntsaninja
Copy link
Contributor

Feel free to re-open if a) your issue is something other than what isidentical mentioned, b) you have a reproducer

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2022
@AlexWaygood
Copy link
Member

AlexWaygood commented May 22, 2022

Feel free to re-open if a) your issue is something other than what isidentical mentioned, b) you have a reproducer

Cc. @davidcastells (I believe "mannequin" users aren't autosubscribed to issues they opened on BPO, even if they're listed on the nosy list)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants