Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(148937)

Side by Side Diff: Objects/object.c

Issue 11610: Improving property to accept abstract methods
Patch Set: Created 8 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Objects/funcobject.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* Generic object operations; and implementation of None */ 2 /* Generic object operations; and implementation of None */
3 3
4 #include "Python.h" 4 #include "Python.h"
5 #include "frameobject.h" 5 #include "frameobject.h"
6 6
7 #ifdef __cplusplus 7 #ifdef __cplusplus
8 extern "C" { 8 extern "C" {
9 #endif 9 #endif
10 10
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 PyObject *s; 820 PyObject *s;
821 int res; 821 int res;
822 822
823 if (Py_TYPE(v)->tp_setattr != NULL) 823 if (Py_TYPE(v)->tp_setattr != NULL)
824 return (*Py_TYPE(v)->tp_setattr)(v, (char*)name, w); 824 return (*Py_TYPE(v)->tp_setattr)(v, (char*)name, w);
825 s = PyUnicode_InternFromString(name); 825 s = PyUnicode_InternFromString(name);
826 if (s == NULL) 826 if (s == NULL)
827 return -1; 827 return -1;
828 res = PyObject_SetAttr(v, s, w); 828 res = PyObject_SetAttr(v, s, w);
829 Py_XDECREF(s); 829 Py_XDECREF(s);
830 return res;
831 }
832
833 int
834 _PyObject_IsAbstract(PyObject *obj)
835 {
836 int res;
837 PyObject* isabstract;
838 _Py_IDENTIFIER(__isabstractmethod__);
839
840 if (obj == NULL)
841 return 0;
842
843 isabstract = _PyObject_GetAttrId(obj, &PyId___isabstractmethod__);
844 if (isabstract == NULL) {
845 if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
846 PyErr_Clear();
847 return 0;
848 }
849 return -1;
850 }
851 res = PyObject_IsTrue(isabstract);
852 Py_DECREF(isabstract);
830 return res; 853 return res;
831 } 854 }
832 855
833 PyObject * 856 PyObject *
834 _PyObject_GetAttrId(PyObject *v, _Py_Identifier *name) 857 _PyObject_GetAttrId(PyObject *v, _Py_Identifier *name)
835 { 858 {
836 PyObject *result; 859 PyObject *result;
837 PyObject *oname = _PyUnicode_FromId(name); /* borrowed */ 860 PyObject *oname = _PyUnicode_FromId(name); /* borrowed */
838 if (!oname) 861 if (!oname)
839 return NULL; 862 return NULL;
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 _Py_Dealloc(PyObject *op) 1912 _Py_Dealloc(PyObject *op)
1890 { 1913 {
1891 _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA 1914 _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA
1892 (*Py_TYPE(op)->tp_dealloc)(op); 1915 (*Py_TYPE(op)->tp_dealloc)(op);
1893 } 1916 }
1894 #endif 1917 #endif
1895 1918
1896 #ifdef __cplusplus 1919 #ifdef __cplusplus
1897 } 1920 }
1898 #endif 1921 #endif
OLDNEW
« no previous file with comments | « Objects/funcobject.c ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+