-
Notifications
You must be signed in to change notification settings - Fork 95
Fixed "print function's "end" option error in CPython" #92
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
Conversation
The following code writes different string to the stream than in CPython: print(1,2,3, end="||\n") The following code writes different string to the stream than in CPython: print(1,2,3, end="||\n") I fixed that bug by modifying the code
Codecov Report
@@ Coverage Diff @@
## master #92 +/- ##
=========================================
+ Coverage 69.09% 69.1% +0.01%
=========================================
Files 60 60
Lines 10674 10678 +4
=========================================
+ Hits 7375 7379 +4
Misses 2781 2781
Partials 518 518
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sungmin-Joo Please add a unit test which you updated.
add "end" test in cpython
@corona10 |
@Sungmin-Joo AS-IS>>> print(1,2,3, end="||\n")
1||
2||
3|| TO-BE>>> print(1,2,3, end="||\n")
1 2 3|| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test is not proper.
@@ -186,6 +186,12 @@ func builtin_print(self py.Object, args py.Tuple, kwargs py.StringDict) (py.Obje | |||
if err != nil { | |||
return nil, err | |||
} | |||
|
|||
if kwargs["sep"] != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about:
switch sep, ok := kwargs["sep"]; ok {
case true:
sepObj = sep
default:
sepObj = py.String(" ")
}
print("hello","gpython", end="123\n") | ||
except TypeError as e: | ||
ok = True | ||
assert ok, "TypeError not raised" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert ok, "TypeError not raised" | |
assert ok, "TypeError not raised when 'sep' is not in the kwargs dict" |
that said, I am not sure I understand this test.
do we really want this line to raise an exception? why?
@@ -281,6 +281,12 @@ def gen2(): | |||
ok = True | |||
assert ok, "TypeError not raised" | |||
|
|||
try: | |||
print("hello","gpython", end="123\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print("hello","gpython", end="123\n") | |
print("hello", "gpython", end="123\n") |
@Sungmin-Joo @sbinet err := py.ParseTupleAndKeywords(nil, kwargs, "|ssOO:print", kwlist, &sepObj, &endObj, &file, &flush) I am now closing this PR |
The following code writes different string to the stream than in CPython:
I fixed that bug by modifying the code
resolved: #93