diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/if_py_both.h | 25 | ||||
-rw-r--r-- | src/testdir/test86.in | 12 | ||||
-rw-r--r-- | src/testdir/test86.ok | 14 | ||||
-rw-r--r-- | src/testdir/test87.in | 12 | ||||
-rw-r--r-- | src/testdir/test87.ok | 14 | ||||
-rw-r--r-- | src/version.c | 2 |
6 files changed, 75 insertions, 4 deletions
diff --git a/src/if_py_both.h b/src/if_py_both.h index 497db8665..e2f4857e4 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -465,20 +465,41 @@ OutputWritelines(OutputObject *self, PyObject *seq) } static PyObject * -OutputFlush(PyObject *self UNUSED) +AlwaysNone(PyObject *self UNUSED) { /* do nothing */ Py_INCREF(Py_None); return Py_None; } + static PyObject * +AlwaysFalse(PyObject *self UNUSED) +{ + /* do nothing */ + Py_INCREF(Py_False); + return Py_False; +} + + static PyObject * +AlwaysTrue(PyObject *self UNUSED) +{ + /* do nothing */ + Py_INCREF(Py_True); + return Py_True; +} + /***************/ static struct PyMethodDef OutputMethods[] = { /* name, function, calling, doc */ {"write", (PyCFunction)OutputWrite, METH_O, ""}, {"writelines", (PyCFunction)OutputWritelines, METH_O, ""}, - {"flush", (PyCFunction)OutputFlush, METH_NOARGS, ""}, + {"flush", (PyCFunction)AlwaysNone, METH_NOARGS, ""}, + {"close", (PyCFunction)AlwaysNone, METH_NOARGS, ""}, + {"isatty", (PyCFunction)AlwaysFalse, METH_NOARGS, ""}, + {"readable", (PyCFunction)AlwaysFalse, METH_NOARGS, ""}, + {"seekable", (PyCFunction)AlwaysFalse, METH_NOARGS, ""}, + {"writable", (PyCFunction)AlwaysTrue, METH_NOARGS, ""}, {"__dir__", (PyCFunction)OutputDir, METH_NOARGS, ""}, { NULL, NULL, 0, NULL} }; diff --git a/src/testdir/test86.in b/src/testdir/test86.in index 819ae9587..32888f836 100644 --- a/src/testdir/test86.in +++ b/src/testdir/test86.in @@ -1094,8 +1094,20 @@ cb.append(">> OutputSetattr") ee('del sys.stdout.softspace') number_test('sys.stdout.softspace = %s', unsigned=True) number_test('sys.stderr.softspace = %s', unsigned=True) +ee('assert sys.stdout.isatty()==False') +ee('assert sys.stdout.seekable()==False') +ee('sys.stdout.close()') +ee('sys.stdout.flush()') +ee('assert sys.stderr.isatty()==False') +ee('assert sys.stderr.seekable()==False') +ee('sys.stderr.close()') +ee('sys.stderr.flush()') ee('sys.stdout.attr = None') cb.append(">> OutputWrite") +ee('assert sys.stdout.writable()==True') +ee('assert sys.stdout.readable()==False') +ee('assert sys.stderr.writable()==True') +ee('assert sys.stderr.readable()==False') ee('sys.stdout.write(None)') cb.append(">> OutputWriteLines") ee('sys.stdout.writelines(None)') diff --git a/src/testdir/test86.ok b/src/testdir/test86.ok index 8edb74997..5cb0ac574 100644 --- a/src/testdir/test86.ok +++ b/src/testdir/test86.ok @@ -447,7 +447,7 @@ range:__dir__,__members__,append,end,start dictionary:__dir__,__members__,get,has_key,items,keys,locked,pop,popitem,scope,update,values list:__dir__,__members__,extend,locked function:__dir__,__members__,softspace -output:__dir__,__members__,flush,softspace,write,writelines +output:__dir__,__members__,close,flush,isatty,readable,seekable,softspace,writable,write,writelines {} {'a': 1} {'a': 1} @@ -488,8 +488,20 @@ sys.stderr.softspace = []:TypeError:('expected int(), long() or something suppor sys.stderr.softspace = None:TypeError:('expected int(), long() or something supporting coercing to long(), but got NoneType',) sys.stderr.softspace = -1:ValueError:('number must be greater or equal to zero',) <<< Finished +assert sys.stdout.isatty()==False:NOT FAILED +assert sys.stdout.seekable()==False:NOT FAILED +sys.stdout.close():NOT FAILED +sys.stdout.flush():NOT FAILED +assert sys.stderr.isatty()==False:NOT FAILED +assert sys.stderr.seekable()==False:NOT FAILED +sys.stderr.close():NOT FAILED +sys.stderr.flush():NOT FAILED sys.stdout.attr = None:AttributeError:('invalid attribute: attr',) >> OutputWrite +assert sys.stdout.writable()==True:NOT FAILED +assert sys.stdout.readable()==False:NOT FAILED +assert sys.stderr.writable()==True:NOT FAILED +assert sys.stderr.readable()==False:NOT FAILED sys.stdout.write(None):TypeError:('coercing to Unicode: need string or buffer, NoneType found',) >> OutputWriteLines sys.stdout.writelines(None):TypeError:("'NoneType' object is not iterable",) diff --git a/src/testdir/test87.in b/src/testdir/test87.in index e24df4131..fedc7959f 100644 --- a/src/testdir/test87.in +++ b/src/testdir/test87.in @@ -1071,8 +1071,20 @@ cb.append(">> OutputSetattr") ee('del sys.stdout.softspace') number_test('sys.stdout.softspace = %s', unsigned=True) number_test('sys.stderr.softspace = %s', unsigned=True) +ee('assert sys.stdout.isatty()==False') +ee('assert sys.stdout.seekable()==False') +ee('sys.stdout.close()') +ee('sys.stdout.flush()') +ee('assert sys.stderr.isatty()==False') +ee('assert sys.stderr.seekable()==False') +ee('sys.stderr.close()') +ee('sys.stderr.flush()') ee('sys.stdout.attr = None') cb.append(">> OutputWrite") +ee('assert sys.stdout.writable()==True') +ee('assert sys.stdout.readable()==False') +ee('assert sys.stderr.writable()==True') +ee('assert sys.stderr.readable()==False') ee('sys.stdout.write(None)') cb.append(">> OutputWriteLines") ee('sys.stdout.writelines(None)') diff --git a/src/testdir/test87.ok b/src/testdir/test87.ok index e616544b5..777173393 100644 --- a/src/testdir/test87.ok +++ b/src/testdir/test87.ok @@ -447,7 +447,7 @@ range:__dir__,append,end,start dictionary:__dir__,get,has_key,items,keys,locked,pop,popitem,scope,update,values list:__dir__,extend,locked function:__dir__,softspace -output:__dir__,flush,softspace,write,writelines +output:__dir__,close,flush,isatty,readable,seekable,softspace,writable,write,writelines {} {'a': 1} {'a': 1} @@ -488,8 +488,20 @@ sys.stderr.softspace = []:(<class 'TypeError'>, TypeError('expected int() or som sys.stderr.softspace = None:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got NoneType',)) sys.stderr.softspace = -1:(<class 'ValueError'>, ValueError('number must be greater or equal to zero',)) <<< Finished +assert sys.stdout.isatty()==False:NOT FAILED +assert sys.stdout.seekable()==False:NOT FAILED +sys.stdout.close():NOT FAILED +sys.stdout.flush():NOT FAILED +assert sys.stderr.isatty()==False:NOT FAILED +assert sys.stderr.seekable()==False:NOT FAILED +sys.stderr.close():NOT FAILED +sys.stderr.flush():NOT FAILED sys.stdout.attr = None:(<class 'AttributeError'>, AttributeError('invalid attribute: attr',)) >> OutputWrite +assert sys.stdout.writable()==True:NOT FAILED +assert sys.stdout.readable()==False:NOT FAILED +assert sys.stderr.writable()==True:NOT FAILED +assert sys.stderr.readable()==False:NOT FAILED sys.stdout.write(None):(<class 'TypeError'>, TypeError("Can't convert 'NoneType' object to str implicitly",)) >> OutputWriteLines sys.stdout.writelines(None):(<class 'TypeError'>, TypeError("'NoneType' object is not iterable",)) diff --git a/src/version.c b/src/version.c index b818813ff..4f461fe37 100644 --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 905, +/**/ 904, /**/ 903, |