Skip to content

Commit

Permalink
Merge pull request #627 from python-rope/lieryan-fix-octal-literal
Browse files Browse the repository at this point in the history
Fix parsing of octal literal by patchedast
  • Loading branch information
lieryan committed Dec 22, 2022
2 parents cc3b0f9 + 9f28943 commit fb38b83
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
13 changes: 7 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# **Upcoming release**

- #604 Fix test that sometimes leaves files behind in the current working directory (@lieryan)
- #606 Deprecate compress_objectdb and compress_history
- #607 Remove importing from legacy files with `.pickle` suffix
- #625 Remove support for deprecated ast nodes
- #616, #621 Remove `file` builtins
- #626 Install pre-commit hooks on rope repository
- #548 Implement MoveGlobal using string as destination module names
- #606 Deprecate compress_objectdb and compress_history (@lieryan)
- #607 Remove importing from legacy files with `.pickle` suffix (@lieryan)
- #625 Remove support for deprecated ast nodes (@lieryan)
- #616, #621 Remove `file` builtins (@edreamleo)
- #626 Install pre-commit hooks on rope repository (@lieryan)
- #548 Implement MoveGlobal using string as destination module names (@lieryan)
- #627 Fix parsing of octal literal (@lieryan)

# Release 1.6.0

Expand Down
2 changes: 1 addition & 1 deletion rope/refactor/patchedast.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ def __getslice__(self, i, j):

def _get_number_pattern(self):
# HACK: It is merely an approaximation and does the job
integer = r"\-?(0x[\da-fA-F]+|\d+)"
integer = r"\-?(0[xo][\da-fA-F]+|\d+)"
return r"(%s(\.\d*)?|(\.\d+))([eE][-+]?\d+)?[jJ]?" % integer

_string_pattern = None
Expand Down
5 changes: 3 additions & 2 deletions ropetest/refactor/patchedasttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,14 @@ def test_hex_integer_literals_and_region(self):
checker.check_region("Num", start, start + 3)

def test_octal_integer_literals_and_region(self):
source = "a = -0125e1\n"
source = "a = -0o1251\n"
ast_frag = patchedast.get_patched_ast(source, True)
checker = _ResultChecker(self, ast_frag)
start = source.index("-0125e1") + 1
start = source.index("-0o1251") + 1
end = start + 6
# Python 3 parses as UnaryOp(op=USub(), operand=Num(n=10))
checker.check_region("Num", start, end)
checker.check_children("Num", ["0o1251"])

def test_integer_literals_and_sorted_children(self):
source = "a = 10\n"
Expand Down

0 comments on commit fb38b83

Please sign in to comment.