self.assertEqual(0, f.fileno())
f.close() # multiple close should not crash
f.close()
+ with self.assertWarns(RuntimeWarning):
+ with ConIO(False):
+ pass
try:
f = ConIO(1, 'w')
self.assertEqual(1, f.fileno())
f.close()
f.close()
+ with self.assertWarns(RuntimeWarning):
+ with ConIO(False):
+ pass
try:
f = ConIO(2, 'w')
self->fd = -1;
}
+ if (PyBool_Check(nameobj)) {
+ if (PyErr_WarnEx(PyExc_RuntimeWarning,
+ "bool is used as a file descriptor", 1))
+ {
+ return -1;
+ }
+ }
fd = PyLong_AsInt(nameobj);
if (fd < 0) {
if (!PyErr_Occurred()) {