Skip to content

Commit ee05c4a

Browse files
committed
Add comments
1 parent 66f7ceb commit ee05c4a

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ PCode compile(String expression, String filename, String mode, Object kwFlags, O
731731
ParserMode pm;
732732
if (mode.equals("exec")) {
733733
pm = ParserMode.File;
734+
// CPython adds a newline and we need to do the same in order to produce
735+
// SyntaxError with the same offset when the line is incomplete
734736
if (!code.endsWith("\n")) {
735737
code += '\n';
736738
}

graalpython/lib-graalpython/sys.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ def __print_traceback__(typ, value, tb):
185185
try:
186186
import traceback
187187
lines = traceback.format_exception(typ, value, tb)
188+
# CPython's C traceback printer diverges from traceback.print_exception in this small detail.
189+
# We'd like to contribute to CPython to fix the divergence, but for now we do just
190+
# a string substitution to pass the tests
188191
lines[-1] = lines[-1].replace(f'<unprintable {typ.__name__} object>', f'<exception str() failed>')
189192
for line in lines:
190193
print(line, file=stderr, end="")

0 commit comments

Comments
 (0)