| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 75a8b72 commit e26be87
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -386,7 +386,8 @@ void unicode_dealloc(register PyUnicodeObject *unicode) | |||
| 386 | 386 | } | |
| 387 | 387 | } | |
| 388 | 388 | ||
| 389 | - int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length) | ||
| 389 | + static | ||
| 390 | + int _PyUnicode_Resize(PyUnicodeObject **unicode, Py_ssize_t length) | ||
| 390 | 391 | { | |
| 391 | 392 | register PyUnicodeObject *v; | |
| 392 | 393 | ||
@@ -395,7 +396,7 @@ int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length) | |||
| 395 | 396 | PyErr_BadInternalCall(); | |
| 396 | 397 | return -1; | |
| 397 | 398 | } | |
| 398 | - v = (PyUnicodeObject *)*unicode; | ||
| 399 | + v = *unicode; | ||
| 399 | 400 | if (v == NULL || !PyUnicode_Check(v) || Py_REFCNT(v) != 1 || length < 0) { | |
| 400 | 401 | PyErr_BadInternalCall(); | |
| 401 | 402 | return -1; | |
@@ -412,7 +413,7 @@ int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length) | |||
| 412 | 413 | Py_UNICODE_COPY(w->str, v->str, | |
| 413 | 414 | length < v->length ? length : v->length); | |
| 414 | 415 | Py_DECREF(*unicode); | |
| 415 | - *unicode = (PyObject *)w; | ||
| 416 | + *unicode = w; | ||
| 416 | 417 | return 0; | |
| 417 | 418 | } | |
| 418 | 419 | ||
@@ -421,9 +422,10 @@ int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length) | |||
| 421 | 422 | return unicode_resize(v, length); | |
| 422 | 423 | } | |
| 423 | 424 | ||
| 424 | - /* Internal API for use in unicodeobject.c only ! */ | ||
| 425 | - #define _PyUnicode_Resize(unicodevar, length) \ | ||
| 426 | - PyUnicode_Resize(((PyObject **)(unicodevar)), length) | ||
| 425 | + int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length) | ||
| 426 | + { | ||
| 427 | + return _PyUnicode_Resize((PyUnicodeObject **)unicode, length); | ||
| 428 | + } | ||
| 427 | 429 | ||
| 428 | 430 | PyObject *PyUnicode_FromUnicode(const Py_UNICODE *u, | |
| 429 | 431 | Py_ssize_t size) | |
@@ -937,7 +939,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs) | |||
| 937 | 939 | PyObject_Free(callresults); | |
| 938 | 940 | if (abuffer) | |
| 939 | 941 | PyObject_Free(abuffer); | |
| 940 | - _PyUnicode_Resize(&string, s - PyUnicode_AS_UNICODE(string)); | ||
| 942 | + PyUnicode_Resize(&string, s - PyUnicode_AS_UNICODE(string)); | ||
| 941 | 943 | return string; | |
| 942 | 944 | fail: | |
| 943 | 945 | if (callresults) { | |
@@ -1345,7 +1347,7 @@ int unicode_decode_call_errorhandler(const char *errors, PyObject **errorHandler | |||
| 1345 | 1347 | const char *encoding, const char *reason, | |
| 1346 | 1348 | const char *input, Py_ssize_t insize, Py_ssize_t *startinpos, | |
| 1347 | 1349 | Py_ssize_t *endinpos, PyObject **exceptionObject, const char **inptr, | |
| 1348 | - PyObject **output, Py_ssize_t *outpos, Py_UNICODE **outptr) | ||
| 1350 | + PyUnicodeObject **output, Py_ssize_t *outpos, Py_UNICODE **outptr) | ||
| 1349 | 1351 | { | |
| 1350 | 1352 | static char *argparse = "O!n;decoding error handler must return (unicode, int) tuple"; | |
| 1351 | 1353 | ||
@@ -1405,7 +1407,7 @@ int unicode_decode_call_errorhandler(const char *errors, PyObject **errorHandler | |||
| 1405 | 1407 | if (requiredsize > outsize) { | |
| 1406 | 1408 | if (requiredsize<2*outsize) | |
| 1407 | 1409 | requiredsize = 2*outsize; | |
| 1408 | - if (PyUnicode_Resize(output, requiredsize) < 0) | ||
| 1410 | + if (_PyUnicode_Resize(output, requiredsize) < 0) | ||
| 1409 | 1411 | goto onError; | |
| 1410 | 1412 | *outptr = PyUnicode_AS_UNICODE(*output) + *outpos; | |
| 1411 | 1413 | } | |
@@ -1604,7 +1606,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s, | |||
| 1604 | 1606 | errors, &errorHandler, | |
| 1605 | 1607 | "utf7", errmsg, | |
| 1606 | 1608 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 1607 | - (PyObject **)&unicode, &outpos, &p)) | ||
| 1609 | + &unicode, &outpos, &p)) | ||
| 1608 | 1610 | goto onError; | |
| 1609 | 1611 | } | |
| 1610 | 1612 | ||
@@ -1615,7 +1617,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s, | |||
| 1615 | 1617 | errors, &errorHandler, | |
| 1616 | 1618 | "utf7", "unterminated shift sequence", | |
| 1617 | 1619 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 1618 | - (PyObject **)&unicode, &outpos, &p)) | ||
| 1620 | + &unicode, &outpos, &p)) | ||
| 1619 | 1621 | goto onError; | |
| 1620 | 1622 | if (s < e) | |
| 1621 | 1623 | goto restart; | |
@@ -1942,7 +1944,7 @@ PyObject *PyUnicode_DecodeUTF8Stateful(const char *s, | |||
| 1942 | 1944 | errors, &errorHandler, | |
| 1943 | 1945 | "utf8", errmsg, | |
| 1944 | 1946 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 1945 | - (PyObject **)&unicode, &outpos, &p)) | ||
| 1947 | + &unicode, &outpos, &p)) | ||
| 1946 | 1948 | goto onError; | |
| 1947 | 1949 | } | |
| 1948 | 1950 | if (consumed) | |
@@ -2222,7 +2224,7 @@ PyUnicode_DecodeUTF32Stateful(const char *s, | |||
| 2222 | 2224 | errors, &errorHandler, | |
| 2223 | 2225 | "utf32", errmsg, | |
| 2224 | 2226 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 2225 | - (PyObject **)&unicode, &outpos, &p)) | ||
| 2227 | + &unicode, &outpos, &p)) | ||
| 2226 | 2228 | goto onError; | |
| 2227 | 2229 | } | |
| 2228 | 2230 | ||
@@ -2496,7 +2498,7 @@ PyUnicode_DecodeUTF16Stateful(const char *s, | |||
| 2496 | 2498 | errors, &errorHandler, | |
| 2497 | 2499 | "utf16", errmsg, | |
| 2498 | 2500 | starts, size, &startinpos, &endinpos, &exc, (const char **)&q, | |
| 2499 | - (PyObject **)&unicode, &outpos, &p)) | ||
| 2501 | + &unicode, &outpos, &p)) | ||
| 2500 | 2502 | goto onError; | |
| 2501 | 2503 | } | |
| 2502 | 2504 | ||
@@ -2717,7 +2719,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, | |||
| 2717 | 2719 | errors, &errorHandler, | |
| 2718 | 2720 | "unicodeescape", "end of string in escape sequence", | |
| 2719 | 2721 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 2720 | - (PyObject **)&v, &outpos, &p)) | ||
| 2722 | + &v, &outpos, &p)) | ||
| 2721 | 2723 | goto onError; | |
| 2722 | 2724 | goto nextByte; | |
| 2723 | 2725 | } | |
@@ -2729,7 +2731,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, | |||
| 2729 | 2731 | errors, &errorHandler, | |
| 2730 | 2732 | "unicodeescape", message, | |
| 2731 | 2733 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 2732 | - (PyObject **)&v, &outpos, &p)) | ||
| 2734 | + &v, &outpos, &p)) | ||
| 2733 | 2735 | goto onError; | |
| 2734 | 2736 | goto nextByte; | |
| 2735 | 2737 | } | |
@@ -2768,7 +2770,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, | |||
| 2768 | 2770 | errors, &errorHandler, | |
| 2769 | 2771 | "unicodeescape", "illegal Unicode character", | |
| 2770 | 2772 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 2771 | - (PyObject **)&v, &outpos, &p)) | ||
| 2773 | + &v, &outpos, &p)) | ||
| 2772 | 2774 | goto onError; | |
| 2773 | 2775 | } | |
| 2774 | 2776 | break; | |
@@ -2810,7 +2812,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, | |||
| 2810 | 2812 | errors, &errorHandler, | |
| 2811 | 2813 | "unicodeescape", message, | |
| 2812 | 2814 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 2813 | - (PyObject **)&v, &outpos, &p)) | ||
| 2815 | + &v, &outpos, &p)) | ||
| 2814 | 2816 | goto onError; | |
| 2815 | 2817 | break; | |
| 2816 | 2818 | ||
@@ -2824,7 +2826,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, | |||
| 2824 | 2826 | errors, &errorHandler, | |
| 2825 | 2827 | "unicodeescape", message, | |
| 2826 | 2828 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 2827 | - (PyObject **)&v, &outpos, &p)) | ||
| 2829 | + &v, &outpos, &p)) | ||
| 2828 | 2830 | goto onError; | |
| 2829 | 2831 | } | |
| 2830 | 2832 | else { | |
@@ -3113,7 +3115,7 @@ PyObject *PyUnicode_DecodeRawUnicodeEscape(const char *s, | |||
| 3113 | 3115 | errors, &errorHandler, | |
| 3114 | 3116 | "rawunicodeescape", "truncated \\uXXXX", | |
| 3115 | 3117 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 3116 | - (PyObject **)&v, &outpos, &p)) | ||
| 3118 | + &v, &outpos, &p)) | ||
| 3117 | 3119 | goto onError; | |
| 3118 | 3120 | goto nextByte; | |
| 3119 | 3121 | } | |
@@ -3145,7 +3147,7 @@ PyObject *PyUnicode_DecodeRawUnicodeEscape(const char *s, | |||
| 3145 | 3147 | errors, &errorHandler, | |
| 3146 | 3148 | "rawunicodeescape", "\\Uxxxxxxxx out of range", | |
| 3147 | 3149 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 3148 | - (PyObject **)&v, &outpos, &p)) | ||
| 3150 | + &v, &outpos, &p)) | ||
| 3149 | 3151 | goto onError; | |
| 3150 | 3152 | } | |
| 3151 | 3153 | nextByte: | |
@@ -3315,7 +3317,7 @@ PyObject *_PyUnicode_DecodeUnicodeInternal(const char *s, | |||
| 3315 | 3317 | errors, &errorHandler, | |
| 3316 | 3318 | "unicode_internal", reason, | |
| 3317 | 3319 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 3318 | - (PyObject **)&v, &outpos, &p)) { | ||
| 3320 | + &v, &outpos, &p)) { | ||
| 3319 | 3321 | goto onError; | |
| 3320 | 3322 | } | |
| 3321 | 3323 | } | |
@@ -3695,7 +3697,7 @@ PyObject *PyUnicode_DecodeASCII(const char *s, | |||
| 3695 | 3697 | errors, &errorHandler, | |
| 3696 | 3698 | "ascii", "ordinal not in range(128)", | |
| 3697 | 3699 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 3698 | - (PyObject **)&v, &outpos, &p)) | ||
| 3700 | + &v, &outpos, &p)) | ||
| 3699 | 3701 | goto onError; | |
| 3700 | 3702 | } | |
| 3701 | 3703 | } | |
@@ -3996,7 +3998,7 @@ PyObject *PyUnicode_DecodeCharmap(const char *s, | |||
| 3996 | 3998 | errors, &errorHandler, | |
| 3997 | 3999 | "charmap", "character maps to <undefined>", | |
| 3998 | 4000 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 3999 | - (PyObject **)&v, &outpos, &p)) { | ||
| 4001 | + &v, &outpos, &p)) { | ||
| 4000 | 4002 | goto onError; | |
| 4001 | 4003 | } | |
| 4002 | 4004 | continue; | |
@@ -4046,7 +4048,7 @@ PyObject *PyUnicode_DecodeCharmap(const char *s, | |||
| 4046 | 4048 | errors, &errorHandler, | |
| 4047 | 4049 | "charmap", "character maps to <undefined>", | |
| 4048 | 4050 | starts, size, &startinpos, &endinpos, &exc, &s, | |
| 4049 | - (PyObject **)&v, &outpos, &p)) { | ||
| 4051 | + &v, &outpos, &p)) { | ||
| 4050 | 4052 | Py_DECREF(x); | |
| 4051 | 4053 | goto onError; | |
| 4052 | 4054 | } | |
@@ -4797,7 +4799,7 @@ int charmaptranslate_makespace(PyObject **outobj, Py_UNICODE **outp, | |||
| 4797 | 4799 | /* exponentially overallocate to minimize reallocations */ | |
| 4798 | 4800 | if (requiredsize < 2 * oldsize) | |
| 4799 | 4801 | requiredsize = 2 * oldsize; | |
| 4800 | - if (_PyUnicode_Resize(outobj, requiredsize) < 0) | ||
| 4802 | + if (PyUnicode_Resize(outobj, requiredsize) < 0) | ||
| 4801 | 4803 | return -1; | |
| 4802 | 4804 | *outp = PyUnicode_AS_UNICODE(*outobj) + outpos; | |
| 4803 | 4805 | } | |
@@ -4976,7 +4978,7 @@ PyObject *PyUnicode_TranslateCharmap(const Py_UNICODE *p, | |||
| 4976 | 4978 | /* Resize if we allocated to much */ | |
| 4977 | 4979 | respos = str-PyUnicode_AS_UNICODE(res); | |
| 4978 | 4980 | if (respos<PyUnicode_GET_SIZE(res)) { | |
| 4979 | - if (_PyUnicode_Resize(&res, respos) < 0) | ||
| 4981 | + if (PyUnicode_Resize(&res, respos) < 0) | ||
| 4980 | 4982 | goto onError; | |
| 4981 | 4983 | } | |
| 4982 | 4984 | Py_XDECREF(exc); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments