Skip to content

Commit

Permalink
Merge pull request #423 from impact27/fix_lineno_range
Browse files Browse the repository at this point in the history
PR: Fix lineno range
  • Loading branch information
ccordoba12 authored Oct 19, 2022
2 parents 26c5e23 + 37ff0dc commit 18acdb2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spyder_kernels/customize/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import ast
import os
import re
import sys
import sysconfig


Expand Down Expand Up @@ -113,6 +114,14 @@ def capture_last_Expr(code_ast, out_varname):
# Fix line number and column offset
assign_node.lineno = expr_node.lineno
assign_node.col_offset = expr_node.col_offset
if sys.version_info[:2] >= (3, 8):
# Exists from 3.8, necessary from 3.11
assign_node.end_lineno = expr_node.end_lineno
if assign_node.lineno == assign_node.end_lineno:
# Add 'globals()[{}] = ' and remove 'None'
assign_node.end_col_offset += expr_node.end_col_offset - 4
else:
assign_node.end_col_offset = expr_node.end_col_offset
code_ast.body[-1] = assign_node
return code_ast, capture_last_expression

Expand Down

0 comments on commit 18acdb2

Please sign in to comment.