Skip to content

Instantly share code, notes, and snippets.

@rgrig
Last active January 1, 2016 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgrig/8208981 to your computer and use it in GitHub Desktop.
Save rgrig/8208981 to your computer and use it in GitHub Desktop.
diff -r e5fa13aae1cc Python/bltinmodule.c
--- a/Python/bltinmodule.c Tue Dec 31 06:52:47 2013 -0500
+++ b/Python/bltinmodule.c Wed Jan 01 15:46:01 2014 +0000
@@ -1559,14 +1559,15 @@
equivalent to (x**y) % z, but may be more efficient (e.g. for ints).");
-
static PyObject *
builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
{
+static PyObject *endline = 0;
static char *kwlist[] = {"sep", "end", "file", "flush", 0};
static PyObject *dummy_args;
PyObject *sep = NULL, *end = NULL, *file = NULL, *flush = NULL;
int i, err;
+if(!endline) endline=PyUnicode_FromString("\n");
if (dummy_args == NULL && !(dummy_args = PyTuple_New(0)))
return NULL;
@@ -1621,7 +1623,8 @@
}
if (end == NULL)
- err = PyFile_WriteString("\n", file);
+ //err = PyFile_WriteString("\n", file);
+ err = PyFile_WriteObject(endline, file, Py_PRINT_RAW);
else
err = PyFile_WriteObject(end, file, Py_PRINT_RAW);
if (err)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment