Skip to content

Commit

Permalink
Replace PySys_WriteStdout with PySys_FormatStdout to ensure no trunca…
Browse files Browse the repository at this point in the history
…tion for long lines. Fixes numba#3811.

Signed-off-by: HE, Tao <sighingnow@gmail.com>
  • Loading branch information
sighingnow committed Mar 3, 2019
1 parent ae88a6f commit b01a590
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numba/pythonapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ def borrow_none(self):

def sys_write_stdout(self, fmt, *args):
fnty = Type.function(Type.void(), [self.cstring], var_arg=True)
fn = self._get_function(fnty, name="PySys_WriteStdout")
fn = self._get_function(fnty, name="PySys_FormatStdout")
return self.builder.call(fn, (fmt,) + args)

def object_dump(self, obj):
Expand Down
10 changes: 10 additions & 0 deletions numba/tests/test_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,15 @@ def print_kwarg():
"keyword arguments.")
self.assertIn(raises.exception.msg, expected)

def test_print_no_truncation(self):
''' See: https://github.com/numba/numba/issues/3811
'''
@jit(nopython=True)
def foo():
print(''.join(['a'] * 10000))
with captured_stdout():
foo()
self.assertEqual(sys.stdout.getvalue(), ''.join(['a'] * 10000) + '\n')

if __name__ == '__main__':
unittest.main()

0 comments on commit b01a590

Please sign in to comment.