mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
Fix RecursionError: global statements in modules should just be ignored, fixes #1457
This commit is contained in:
@@ -686,6 +686,11 @@ def tree_name_to_values(inference_state, context, tree_name):
|
|||||||
node = tree_name.parent
|
node = tree_name.parent
|
||||||
if node.type == 'global_stmt':
|
if node.type == 'global_stmt':
|
||||||
c = context.create_context(tree_name)
|
c = context.create_context(tree_name)
|
||||||
|
if c.is_module():
|
||||||
|
# In case we are already part of the module, there is no point
|
||||||
|
# in looking up the global statement anymore, because it's not
|
||||||
|
# valid at that point anyway.
|
||||||
|
return NO_VALUES
|
||||||
# For global_stmt lookups, we only need the first possible scope,
|
# For global_stmt lookups, we only need the first possible scope,
|
||||||
# which means the function itself.
|
# which means the function itself.
|
||||||
filter = next(c.get_filters())
|
filter = next(c.get_filters())
|
||||||
|
|||||||
@@ -196,6 +196,13 @@ def global_as_import():
|
|||||||
globals.foo
|
globals.foo
|
||||||
|
|
||||||
|
|
||||||
|
global r
|
||||||
|
r = r[r]
|
||||||
|
if r:
|
||||||
|
r += r + 2
|
||||||
|
#? int()
|
||||||
|
r
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# within docstrs
|
# within docstrs
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user