Skip to content

Commit d63a3b8

Browse files
committed
Implement PEP 393.
1 parent 48d4949 commit d63a3b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+8125
-5403
lines changed

Doc/c-api/unicode.rst

+9
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,15 @@ They all return *NULL* or ``-1`` if an exception occurs.
10721072
occurred and an exception has been set.
10731073
10741074
1075+
.. c:function:: Py_ssize_t PyUnicode_FindChar(PyObject *str, Py_UCS4 ch, Py_ssize_t start, Py_ssize_t end, int direction)
1076+
1077+
Return the first position of the character *ch* in ``str[start:end]`` using
1078+
the given *direction* (*direction* == 1 means to do a forward search,
1079+
*direction* == -1 a backward search). The return value is the index of the
1080+
first match; a value of ``-1`` indicates that no match was found, and ``-2``
1081+
indicates that an error occurred and an exception has been set.
1082+
1083+
10751084
.. c:function:: Py_ssize_t PyUnicode_Count(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end)
10761085
10771086
Return the number of non-overlapping occurrences of *substr* in

Include/Python.h

+5
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,9 @@ PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
160160
#define PyDoc_STR(str) ""
161161
#endif
162162

163+
#define PY_ARRAY_LENGTH(array) (sizeof(array) / sizeof((array)[0]))
164+
165+
#define PY_MIN(x, y) (((x) > (y)) ? (y) : (x))
166+
#define PY_MAX(x, y) (((x) > (y)) ? (x) : (y))
167+
163168
#endif /* !Py_PYTHON_H */

Include/complexobject.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
6464
(Advanced String Formatting). */
6565
#ifndef Py_LIMITED_API
6666
PyAPI_FUNC(PyObject *) _PyComplex_FormatAdvanced(PyObject *obj,
67-
Py_UNICODE *format_spec,
68-
Py_ssize_t format_spec_len);
67+
PyObject *format_spec,
68+
Py_ssize_t start,
69+
Py_ssize_t end);
6970
#endif
7071

7172
#ifdef __cplusplus

Include/floatobject.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ PyAPI_FUNC(int) PyFloat_ClearFreeList(void);
113113
/* Format the object based on the format_spec, as defined in PEP 3101
114114
(Advanced String Formatting). */
115115
PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
116-
Py_UNICODE *format_spec,
117-
Py_ssize_t format_spec_len);
116+
PyObject *format_spec,
117+
Py_ssize_t start,
118+
Py_ssize_t end);
118119
#endif /* Py_LIMITED_API */
119120

120121
#ifdef __cplusplus

Include/longobject.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
8080
PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
8181
#ifndef Py_LIMITED_API
8282
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
83+
PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base);
8384
#endif
8485

8586
#ifndef Py_LIMITED_API
@@ -155,8 +156,9 @@ PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base);
155156
/* Format the object based on the format_spec, as defined in PEP 3101
156157
(Advanced String Formatting). */
157158
PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj,
158-
Py_UNICODE *format_spec,
159-
Py_ssize_t format_spec_len);
159+
PyObject *format_spec,
160+
Py_ssize_t start,
161+
Py_ssize_t end);
160162
#endif /* Py_LIMITED_API */
161163

162164
/* These aren't really part of the long object, but they're handy. The

Include/pyerrors.h

+6
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
301301
Py_ssize_t end,
302302
const char *reason /* UTF-8 encoded string */
303303
);
304+
PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create(
305+
PyObject *object,
306+
Py_ssize_t start,
307+
Py_ssize_t end,
308+
const char *reason /* UTF-8 encoded string */
309+
);
304310
#endif
305311

306312
/* get the encoding attribute */

Include/pyport.h

+3
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,15 @@ typedef size_t Py_uhash_t;
286286
/* fastest possible local call under MSVC */
287287
#define Py_LOCAL(type) static type __fastcall
288288
#define Py_LOCAL_INLINE(type) static __inline type __fastcall
289+
#define Py_LOCAL_CALLBACK(name) (__fastcall *name)
289290
#elif defined(USE_INLINE)
290291
#define Py_LOCAL(type) static type
291292
#define Py_LOCAL_INLINE(type) static inline type
293+
#define Py_LOCAL_CALLBACK(name) (*name)
292294
#else
293295
#define Py_LOCAL(type) static type
294296
#define Py_LOCAL_INLINE(type) static type
297+
#define Py_LOCAL_CALLBACK(name) (*name)
295298
#endif
296299

297300
/* Py_MEMCPY can be used instead of memcpy in cases where the copied blocks

0 commit comments

Comments
 (0)