Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0ac60199
Commit
0ac60199
authored
May 27, 2007
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the new function object attribute names from py3k.
parent
81a191b3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
Misc/NEWS
Misc/NEWS
+3
-0
Objects/funcobject.c
Objects/funcobject.c
+10
-3
No files found.
Misc/NEWS
View file @
0ac60199
...
...
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
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
deprecated and will be changed/removed in Python 3.0.
...
...
Objects/funcobject.c
View file @
0ac60199
...
...
@@ -161,10 +161,14 @@ PyFunction_SetClosure(PyObject *op, PyObject *closure)
static
PyMemberDef
func_memberlist
[]
=
{
{
"func_closure"
,
T_OBJECT
,
OFF
(
func_closure
),
RESTRICTED
|
READONLY
},
{
"__closure__"
,
T_OBJECT
,
OFF
(
func_closure
),
RESTRICTED
|
READONLY
},
{
"func_doc"
,
T_OBJECT
,
OFF
(
func_doc
),
WRITE_RESTRICTED
},
{
"__doc__"
,
T_OBJECT
,
OFF
(
func_doc
),
WRITE_RESTRICTED
},
{
"func_globals"
,
T_OBJECT
,
OFF
(
func_globals
),
RESTRICTED
|
READONLY
},
{
"__globals__"
,
T_OBJECT
,
OFF
(
func_globals
),
RESTRICTED
|
READONLY
},
{
"__module__"
,
T_OBJECT
,
OFF
(
func_module
),
WRITE_RESTRICTED
},
{
NULL
}
/* Sentinel */
};
...
...
@@ -240,7 +244,7 @@ func_set_code(PyFunctionObject *op, PyObject *value)
* other than a code object. */
if
(
value
==
NULL
||
!
PyCode_Check
(
value
))
{
PyErr_SetString
(
PyExc_TypeError
,
"
func_code
must be set to a code object"
);
"
__code__
must be set to a code object"
);
return
-
1
;
}
nfree
=
PyCode_GetNumFree
((
PyCodeObject
*
)
value
);
...
...
@@ -279,7 +283,7 @@ func_set_name(PyFunctionObject *op, PyObject *value)
* other than a string object. */
if
(
value
==
NULL
||
!
PyString_Check
(
value
))
{
PyErr_SetString
(
PyExc_TypeError
,
"
func_name
must be set to a string object"
);
"
__name__
must be set to a string object"
);
return
-
1
;
}
tmp
=
op
->
func_name
;
...
...
@@ -315,7 +319,7 @@ func_set_defaults(PyFunctionObject *op, PyObject *value)
value
=
NULL
;
if
(
value
!=
NULL
&&
!
PyTuple_Check
(
value
))
{
PyErr_SetString
(
PyExc_TypeError
,
"
func_defaults
must be set to a tuple object"
);
"
__defaults__
must be set to a tuple object"
);
return
-
1
;
}
tmp
=
op
->
func_defaults
;
...
...
@@ -327,8 +331,11 @@ func_set_defaults(PyFunctionObject *op, PyObject *value)
static
PyGetSetDef
func_getsetlist
[]
=
{
{
"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
,
(
setter
)
func_set_defaults
},
{
"__defaults__"
,
(
getter
)
func_get_defaults
,
(
setter
)
func_set_defaults
},
{
"func_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
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment