From 1a587bace9af9b8006ae310bc2f74a8bd6de7091 Mon Sep 17 00:00:00 2001 From: Sungmin-Joo Date: Fri, 27 Sep 2019 12:04:07 +0900 Subject: [PATCH 1/2] Fix "end" option in print function 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 --- builtin/builtin.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builtin/builtin.go b/builtin/builtin.go index 2512e2fd..828f8938 100644 --- a/builtin/builtin.go +++ b/builtin/builtin.go @@ -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 { + sepObj = kwargs["sep"] + } else { + sepObj = py.String(" ") + } sep := sepObj.(py.String) if kwargs["end"] != nil { From 0d6c264509c9ccbffee385acd46bde7ce80cd635 Mon Sep 17 00:00:00 2001 From: Sungmin-Joo Date: Fri, 27 Sep 2019 16:55:16 +0900 Subject: [PATCH 2/2] add "end" test in cpython add "end" test in cpython --- builtin/tests/builtin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builtin/tests/builtin.py b/builtin/tests/builtin.py index e3a1c5a5..231c776d 100644 --- a/builtin/tests/builtin.py +++ b/builtin/tests/builtin.py @@ -281,6 +281,12 @@ def gen2(): ok = True assert ok, "TypeError not raised" +try: + print("hello","gpython", end="123\n") +except TypeError as e: + ok = True +assert ok, "TypeError not raised" + try: print("hello", sep=" ", end=1) except TypeError as e: