Commit 0ac60199 authored by Neal Norwitz's avatar Neal Norwitz

Add the new function object attribute names from py3k.

parent 81a191b3
...@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1? ...@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
Core and builtins Core and builtins
----------------- -----------------
- Add new attribute names for function objects. All the func_* become
__*__ attributes. (Some already existed, e.g., __doc__ and __name__.)
- Add -3 option to the interpreter to warn about features that are - Add -3 option to the interpreter to warn about features that are
deprecated and will be changed/removed in Python 3.0. deprecated and will be changed/removed in Python 3.0.
......
...@@ -161,10 +161,14 @@ PyFunction_SetClosure(PyObject *op, PyObject *closure) ...@@ -161,10 +161,14 @@ PyFunction_SetClosure(PyObject *op, PyObject *closure)
static PyMemberDef func_memberlist[] = { static PyMemberDef func_memberlist[] = {
{"func_closure", T_OBJECT, OFF(func_closure), {"func_closure", T_OBJECT, OFF(func_closure),
RESTRICTED|READONLY}, RESTRICTED|READONLY},
{"__closure__", T_OBJECT, OFF(func_closure),
RESTRICTED|READONLY},
{"func_doc", T_OBJECT, OFF(func_doc), WRITE_RESTRICTED}, {"func_doc", T_OBJECT, OFF(func_doc), WRITE_RESTRICTED},
{"__doc__", T_OBJECT, OFF(func_doc), WRITE_RESTRICTED}, {"__doc__", T_OBJECT, OFF(func_doc), WRITE_RESTRICTED},
{"func_globals", T_OBJECT, OFF(func_globals), {"func_globals", T_OBJECT, OFF(func_globals),
RESTRICTED|READONLY}, RESTRICTED|READONLY},
{"__globals__", T_OBJECT, OFF(func_globals),
RESTRICTED|READONLY},
{"__module__", T_OBJECT, OFF(func_module), WRITE_RESTRICTED}, {"__module__", T_OBJECT, OFF(func_module), WRITE_RESTRICTED},
{NULL} /* Sentinel */ {NULL} /* Sentinel */
}; };
...@@ -240,7 +244,7 @@ func_set_code(PyFunctionObject *op, PyObject *value) ...@@ -240,7 +244,7 @@ func_set_code(PyFunctionObject *op, PyObject *value)
* other than a code object. */ * other than a code object. */
if (value == NULL || !PyCode_Check(value)) { if (value == NULL || !PyCode_Check(value)) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"func_code must be set to a code object"); "__code__ must be set to a code object");
return -1; return -1;
} }
nfree = PyCode_GetNumFree((PyCodeObject *)value); nfree = PyCode_GetNumFree((PyCodeObject *)value);
...@@ -279,7 +283,7 @@ func_set_name(PyFunctionObject *op, PyObject *value) ...@@ -279,7 +283,7 @@ func_set_name(PyFunctionObject *op, PyObject *value)
* other than a string object. */ * other than a string object. */
if (value == NULL || !PyString_Check(value)) { if (value == NULL || !PyString_Check(value)) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"func_name must be set to a string object"); "__name__ must be set to a string object");
return -1; return -1;
} }
tmp = op->func_name; tmp = op->func_name;
...@@ -315,7 +319,7 @@ func_set_defaults(PyFunctionObject *op, PyObject *value) ...@@ -315,7 +319,7 @@ func_set_defaults(PyFunctionObject *op, PyObject *value)
value = NULL; value = NULL;
if (value != NULL && !PyTuple_Check(value)) { if (value != NULL && !PyTuple_Check(value)) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"func_defaults must be set to a tuple object"); "__defaults__ must be set to a tuple object");
return -1; return -1;
} }
tmp = op->func_defaults; tmp = op->func_defaults;
...@@ -327,8 +331,11 @@ func_set_defaults(PyFunctionObject *op, PyObject *value) ...@@ -327,8 +331,11 @@ func_set_defaults(PyFunctionObject *op, PyObject *value)
static PyGetSetDef func_getsetlist[] = { static PyGetSetDef func_getsetlist[] = {
{"func_code", (getter)func_get_code, (setter)func_set_code}, {"func_code", (getter)func_get_code, (setter)func_set_code},
{"__code__", (getter)func_get_code, (setter)func_set_code},
{"func_defaults", (getter)func_get_defaults, {"func_defaults", (getter)func_get_defaults,
(setter)func_set_defaults}, (setter)func_set_defaults},
{"__defaults__", (getter)func_get_defaults,
(setter)func_set_defaults},
{"func_dict", (getter)func_get_dict, (setter)func_set_dict}, {"func_dict", (getter)func_get_dict, (setter)func_set_dict},
{"__dict__", (getter)func_get_dict, (setter)func_set_dict}, {"__dict__", (getter)func_get_dict, (setter)func_set_dict},
{"func_name", (getter)func_get_name, (setter)func_set_name}, {"func_name", (getter)func_get_name, (setter)func_set_name},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment