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
23d7f12f
Commit
23d7f12f
authored
Feb 19, 2012
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use new generic __dict__ descriptor implementations
parent
8eb1269c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
141 deletions
+6
-141
Modules/_functoolsmodule.c
Modules/_functoolsmodule.c
+1
-37
Modules/_io/iobase.c
Modules/_io/iobase.c
+1
-14
Objects/exceptions.c
Objects/exceptions.c
+1
-31
Objects/funcobject.c
Objects/funcobject.c
+3
-59
No files found.
Modules/_functoolsmodule.c
View file @
23d7f12f
...
...
@@ -155,44 +155,8 @@ static PyMemberDef partial_memberlist[] = {
{
NULL
}
/* Sentinel */
};
static
PyObject
*
partial_get_dict
(
partialobject
*
pto
)
{
if
(
pto
->
dict
==
NULL
)
{
pto
->
dict
=
PyDict_New
();
if
(
pto
->
dict
==
NULL
)
return
NULL
;
}
Py_INCREF
(
pto
->
dict
);
return
pto
->
dict
;
}
static
int
partial_set_dict
(
partialobject
*
pto
,
PyObject
*
value
)
{
PyObject
*
tmp
;
/* It is illegal to del p.__dict__ */
if
(
value
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"a partial object's dictionary may not be deleted"
);
return
-
1
;
}
/* Can only set __dict__ to a dictionary */
if
(
!
PyDict_Check
(
value
))
{
PyErr_SetString
(
PyExc_TypeError
,
"setting partial object's dictionary to a non-dict"
);
return
-
1
;
}
tmp
=
pto
->
dict
;
Py_INCREF
(
value
);
pto
->
dict
=
value
;
Py_XDECREF
(
tmp
);
return
0
;
}
static
PyGetSetDef
partial_getsetlist
[]
=
{
{
"__dict__"
,
(
getter
)
partial_get_dict
,
(
setter
)
partial_set_d
ict
},
{
"__dict__"
,
PyObject_GenericGetDict
,
PyObject_GenericSetD
ict
},
{
NULL
}
/* Sentinel */
};
...
...
Modules/_io/iobase.c
View file @
23d7f12f
...
...
@@ -159,19 +159,6 @@ iobase_closed_get(PyObject *self, void *context)
return
PyBool_FromLong
(
IS_CLOSED
(
self
));
}
static
PyObject
*
iobase_get_dict
(
PyObject
*
self
)
{
PyObject
**
dictptr
=
_PyObject_GetDictPtr
(
self
);
PyObject
*
dict
;
assert
(
dictptr
);
dict
=
*
dictptr
;
if
(
dict
==
NULL
)
dict
=
*
dictptr
=
PyDict_New
();
Py_XINCREF
(
dict
);
return
dict
;
}
PyObject
*
_PyIOBase_check_closed
(
PyObject
*
self
,
PyObject
*
args
)
{
...
...
@@ -714,7 +701,7 @@ static PyMethodDef iobase_methods[] = {
};
static
PyGetSetDef
iobase_getset
[]
=
{
{
"__dict__"
,
(
getter
)
iobase_get_d
ict
,
NULL
,
NULL
},
{
"__dict__"
,
PyObject_GenericGetD
ict
,
NULL
,
NULL
},
{
"closed"
,
(
getter
)
iobase_closed_get
,
NULL
,
NULL
},
{
NULL
}
};
...
...
Objects/exceptions.c
View file @
23d7f12f
...
...
@@ -177,36 +177,6 @@ static PyMethodDef BaseException_methods[] = {
{
NULL
,
NULL
,
0
,
NULL
},
};
static
PyObject
*
BaseException_get_dict
(
PyBaseExceptionObject
*
self
)
{
if
(
self
->
dict
==
NULL
)
{
self
->
dict
=
PyDict_New
();
if
(
!
self
->
dict
)
return
NULL
;
}
Py_INCREF
(
self
->
dict
);
return
self
->
dict
;
}
static
int
BaseException_set_dict
(
PyBaseExceptionObject
*
self
,
PyObject
*
val
)
{
if
(
val
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"__dict__ may not be deleted"
);
return
-
1
;
}
if
(
!
PyDict_Check
(
val
))
{
PyErr_SetString
(
PyExc_TypeError
,
"__dict__ must be a dictionary"
);
return
-
1
;
}
Py_CLEAR
(
self
->
dict
);
Py_INCREF
(
val
);
self
->
dict
=
val
;
return
0
;
}
static
PyObject
*
BaseException_get_args
(
PyBaseExceptionObject
*
self
)
{
...
...
@@ -320,7 +290,7 @@ BaseException_set_cause(PyObject *self, PyObject *arg) {
static
PyGetSetDef
BaseException_getset
[]
=
{
{
"__dict__"
,
(
getter
)
BaseException_get_dict
,
(
setter
)
BaseException_set_d
ict
},
{
"__dict__"
,
PyObject_GenericGetDict
,
PyObject_GenericSetD
ict
},
{
"args"
,
(
getter
)
BaseException_get_args
,
(
setter
)
BaseException_set_args
},
{
"__traceback__"
,
(
getter
)
BaseException_get_tb
,
(
setter
)
BaseException_set_tb
},
{
"__context__"
,
(
getter
)
BaseException_get_context
,
...
...
Objects/funcobject.c
View file @
23d7f12f
...
...
@@ -244,42 +244,6 @@ static PyMemberDef func_memberlist[] = {
{
NULL
}
/* Sentinel */
};
static
PyObject
*
func_get_dict
(
PyFunctionObject
*
op
)
{
if
(
op
->
func_dict
==
NULL
)
{
op
->
func_dict
=
PyDict_New
();
if
(
op
->
func_dict
==
NULL
)
return
NULL
;
}
Py_INCREF
(
op
->
func_dict
);
return
op
->
func_dict
;
}
static
int
func_set_dict
(
PyFunctionObject
*
op
,
PyObject
*
value
)
{
PyObject
*
tmp
;
/* It is illegal to del f.func_dict */
if
(
value
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"function's dictionary may not be deleted"
);
return
-
1
;
}
/* Can only set func_dict to a dictionary */
if
(
!
PyDict_Check
(
value
))
{
PyErr_SetString
(
PyExc_TypeError
,
"setting function's dictionary to a non-dict"
);
return
-
1
;
}
tmp
=
op
->
func_dict
;
Py_INCREF
(
value
);
op
->
func_dict
=
value
;
Py_XDECREF
(
tmp
);
return
0
;
}
static
PyObject
*
func_get_code
(
PyFunctionObject
*
op
)
{
...
...
@@ -476,7 +440,7 @@ static PyGetSetDef func_getsetlist[] = {
(
setter
)
func_set_kwdefaults
},
{
"__annotations__"
,
(
getter
)
func_get_annotations
,
(
setter
)
func_set_annotations
},
{
"__dict__"
,
(
getter
)
func_get_dict
,
(
setter
)
func_set_d
ict
},
{
"__dict__"
,
PyObject_GenericGetDict
,
PyObject_GenericSetD
ict
},
{
"__name__"
,
(
getter
)
func_get_name
,
(
setter
)
func_set_name
},
{
"__qualname__"
,
(
getter
)
func_get_qualname
,
(
setter
)
func_set_qualname
},
{
NULL
}
/* Sentinel */
...
...
@@ -831,22 +795,12 @@ cm_get___isabstractmethod__(classmethod *cm, void *closure)
Py_RETURN_FALSE
;
}
static
PyObject
*
cm_get___dict__
(
PyObject
*
cm
,
void
*
closure
)
{
PyObject
**
dictptr
=
_PyObject_GetDictPtr
(
cm
);
if
(
*
dictptr
==
NULL
)
*
dictptr
=
PyDict_New
();
Py_XINCREF
(
*
dictptr
);
return
*
dictptr
;
}
static
PyGetSetDef
cm_getsetlist
[]
=
{
{
"__isabstractmethod__"
,
(
getter
)
cm_get___isabstractmethod__
,
NULL
,
NULL
,
NULL
},
{
"__dict__"
,
(
getter
)
cm_get___dict__
,
NULL
,
NULL
,
NULL
},
{
"__dict__"
,
PyObject_GenericGetDict
,
PyObject_GenericSetDict
,
NULL
,
NULL
},
{
NULL
}
/* Sentinel */
};
...
...
@@ -1020,22 +974,12 @@ sm_get___isabstractmethod__(staticmethod *sm, void *closure)
Py_RETURN_FALSE
;
}
static
PyObject
*
sm_get___dict__
(
PyObject
*
sm
,
void
*
closure
)
{
PyObject
**
dictptr
=
_PyObject_GetDictPtr
(
sm
);
if
(
*
dictptr
==
NULL
)
*
dictptr
=
PyDict_New
();
Py_XINCREF
(
*
dictptr
);
return
*
dictptr
;
}
static
PyGetSetDef
sm_getsetlist
[]
=
{
{
"__isabstractmethod__"
,
(
getter
)
sm_get___isabstractmethod__
,
NULL
,
NULL
,
NULL
},
{
"__dict__"
,
(
getter
)
sm_get___dict__
,
NULL
,
NULL
,
NULL
},
{
"__dict__"
,
PyObject_GenericGetDict
,
PyObject_GenericSetDict
,
NULL
,
NULL
},
{
NULL
}
/* Sentinel */
};
...
...
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