summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-03-21 20:38:24 (GMT)
committerGeorg Brandl <georg@python.org>2008-03-21 20:38:24 (GMT)
commit65bb42dc1be3afe9ad0e5413b7843cc65d9d3a37 (patch)
treee9fcb9f39686f7d1bdd8eecb77c55a36f9902b00 /Objects
parent07e5681fd3a8c7169f569f6b70aa824f203f89d9 (diff)
downloadcpython-65bb42dc1be3afe9ad0e5413b7843cc65d9d3a37.zip
cpython-65bb42dc1be3afe9ad0e5413b7843cc65d9d3a37.tar.gz
cpython-65bb42dc1be3afe9ad0e5413b7843cc65d9d3a37.tar.bz2
#2348: add py3k warning for file.softspace.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/fileobject.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 9195a24..0a6ccff 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -1783,8 +1783,6 @@ static PyMethodDef file_methods[] = {
#define OFF(x) offsetof(PyFileObject, x)
static PyMemberDef file_memberlist[] = {
- {"softspace", T_INT, OFF(f_softspace), 0,
- "flag indicating that a space needs to be printed; used by print"},
{"mode", T_OBJECT, OFF(f_mode), RO,
"file mode ('r', 'U', 'w', 'a', possibly with 'b' or '+' added)"},
{"name", T_OBJECT, OFF(f_name), RO,
@@ -1829,10 +1827,44 @@ get_newlines(PyFileObject *f, void *closure)
}
}
+static PyObject *
+get_softspace(PyFileObject *f, void *closure)
+{
+ if (Py_Py3kWarningFlag &&
+ PyErr_Warn(PyExc_DeprecationWarning,
+ "file.softspace not supported in 3.x") < 0)
+ return NULL;
+ return PyInt_FromLong(f->f_softspace);
+}
+
+static int
+set_softspace(PyFileObject *f, PyObject *value)
+{
+ int new;
+ if (Py_Py3kWarningFlag &&
+ PyErr_Warn(PyExc_DeprecationWarning,
+ "file.softspace not supported in 3.x") < 0)
+ return -1;
+
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError,
+ "can't delete softspace attribute");
+ return -1;
+ }
+
+ new = PyInt_AsLong(value);
+ if (new == -1 && PyErr_Occurred())
+ return -1;
+ f->f_softspace = new;
+ return 0;
+}
+
static PyGetSetDef file_getsetlist[] = {
{"closed", (getter)get_closed, NULL, "True if the file is closed"},
{"newlines", (getter)get_newlines, NULL,
"end-of-line convention used in this file"},
+ {"softspace", (getter)get_softspace, (setter)set_softspace,
+ "flag indicating that a space needs to be printed; used by print"},
{0},
};