Skip to content

Commit c86f222

Browse files
Replace copied code with original code
1 parent c9ded30 commit c86f222

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
THE SOFTWARE.
2222

2323

24-
Two functions in bpython/simpleeval.py are licensed under the
25-
Python Software Foundation License version 2: simple_eval and find_attribute_with_name
24+
One function in bpython/simpleeval.py is licensed under the
25+
Python Software Foundation License version 2: simple_eval
2626

2727
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
2828
--------------------------------------------

bpython/simpleeval.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -155,28 +155,14 @@ def safe_getitem(obj, index):
155155
raise ValueError('unsafe to lookup on object of type %s' % (type(obj), ))
156156

157157

158-
# This function is under the Python License, Version 2
159-
# This license requires modifications to the code be reported.
160-
# Based on ast.NodeVisitor.generic_visit
161-
# Modifications:
162-
# * Now a standalone function instead of method
163-
# * now hardcoded to look for Attribute node with given attr name
164-
# * returns values back up the recursive call stack to stop once target found
165158
def find_attribute_with_name(node, name):
166-
"""Search depth-first for getitem indexing with name"""
167159
if isinstance(node, ast.Attribute) and node.attr == name:
168160
return node
169-
for _, value in ast.iter_fields(node):
170-
if isinstance(value, list):
171-
for item in value:
172-
if isinstance(item, ast.AST):
173-
r = find_attribute_with_name(item, name)
174-
if r:
175-
return r
176-
elif isinstance(value, ast.AST):
177-
r = find_attribute_with_name(value, name)
178-
if r:
179-
return r
161+
for item in ast.iter_child_nodes(node):
162+
r = find_attribute_with_name(item, name)
163+
if r:
164+
return r
165+
180166

181167
def evaluate_current_expression(cursor_offset, line, namespace=None):
182168
"""

0 commit comments

Comments
 (0)