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

Delta Between Two Patch Sets: Objects/abstract.c

Issue 11682: PEP 380 reference implementation for 3.3
Left Patch Set: Created 7 years, 9 months ago
Right Patch Set: Created 7 years, 7 months 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* Abstract Object Interface (many thanks to Jim Fulton) */ 1 /* Abstract Object Interface (many thanks to Jim Fulton) */
2 2
3 #include "Python.h" 3 #include "Python.h"
4 #include <ctype.h> 4 #include <ctype.h>
5 #include "structmember.h" /* we need the offsetof() macro from there */ 5 #include "structmember.h" /* we need the offsetof() macro from there */
6 #include "longintrepr.h" 6 #include "longintrepr.h"
7 7
8 8
9 9
10 /* Shorthands to return certain errors */ 10 /* Shorthands to return certain errors */
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 PyObject * 694 PyObject *
695 PyObject_Format(PyObject *obj, PyObject *format_spec) 695 PyObject_Format(PyObject *obj, PyObject *format_spec)
696 { 696 {
697 PyObject *meth; 697 PyObject *meth;
698 PyObject *empty = NULL; 698 PyObject *empty = NULL;
699 PyObject *result = NULL; 699 PyObject *result = NULL;
700 static PyObject *format_cache = NULL; 700 static PyObject *format_cache = NULL;
701 701
702 /* If no format_spec is provided, use an empty string */ 702 /* If no format_spec is provided, use an empty string */
703 if (format_spec == NULL) { 703 if (format_spec == NULL) {
704 empty = PyUnicode_FromUnicode(NULL, 0); 704 empty = PyUnicode_New(0, 0);
705 format_spec = empty; 705 format_spec = empty;
706 } 706 }
707 707
708 /* Find the (unbound!) __format__ method (a borrowed reference) */ 708 /* Find the (unbound!) __format__ method (a borrowed reference) */
709 meth = _PyObject_LookupSpecial(obj, "__format__", &format_cache); 709 meth = _PyObject_LookupSpecial(obj, "__format__", &format_cache);
710 if (meth == NULL) { 710 if (meth == NULL) {
711 if (!PyErr_Occurred()) 711 if (!PyErr_Occurred())
712 PyErr_Format(PyExc_TypeError, 712 PyErr_Format(PyExc_TypeError,
713 "Type %.100s doesn't define __format__", 713 "Type %.100s doesn't define __format__",
714 Py_TYPE(obj)->tp_name); 714 Py_TYPE(obj)->tp_name);
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 PySequence_Index(PyObject *s, PyObject *o) 1977 PySequence_Index(PyObject *s, PyObject *o)
1978 { 1978 {
1979 return _PySequence_IterSearch(s, o, PY_ITERSEARCH_INDEX); 1979 return _PySequence_IterSearch(s, o, PY_ITERSEARCH_INDEX);
1980 } 1980 }
1981 1981
1982 /* Operations on mappings */ 1982 /* Operations on mappings */
1983 1983
1984 int 1984 int
1985 PyMapping_Check(PyObject *o) 1985 PyMapping_Check(PyObject *o)
1986 { 1986 {
1987 return o && o->ob_type->tp_as_mapping && 1987 return o && o->ob_type->tp_as_mapping &&
1988 o->ob_type->tp_as_mapping->mp_subscript; 1988 o->ob_type->tp_as_mapping->mp_subscript;
1989 } 1989 }
1990 1990
1991 Py_ssize_t 1991 Py_ssize_t
1992 PyMapping_Size(PyObject *o) 1992 PyMapping_Size(PyObject *o)
1993 { 1993 {
1994 PyMappingMethods *m; 1994 PyMappingMethods *m;
1995 1995
1996 if (o == NULL) { 1996 if (o == NULL) {
1997 null_error(); 1997 null_error();
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
2798 /* Free's a NULL terminated char** array of C strings. */ 2798 /* Free's a NULL terminated char** array of C strings. */
2799 void 2799 void
2800 _Py_FreeCharPArray(char *const array[]) 2800 _Py_FreeCharPArray(char *const array[])
2801 { 2801 {
2802 Py_ssize_t i; 2802 Py_ssize_t i;
2803 for (i = 0; array[i] != NULL; ++i) { 2803 for (i = 0; array[i] != NULL; ++i) {
2804 free(array[i]); 2804 free(array[i]);
2805 } 2805 }
2806 free((void*)array); 2806 free((void*)array);
2807 } 2807 }
LEFTRIGHT

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