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

Fix parsing of octal literal by patchedast #627

Merged
merged 2 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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