Skip to content

Commit 27975d9

Browse files
committed
Standardize unicode function/method parameter names across both headers
and code
1 parent 0f2f35e commit 27975d9

File tree

4 files changed

+694
-669
lines changed

4 files changed

+694
-669
lines changed

Include/cpython/unicodeobject.h

Lines changed: 57 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,13 @@ PyAPI_FUNC(void) _PyUnicode_FastFill(
556556
Scan the string to find the maximum character. */
557557
PyAPI_FUNC(PyObject*) PyUnicode_FromKindAndData(
558558
int kind,
559-
const void *buffer,
559+
const void *str,
560560
Py_ssize_t size);
561561

562562
/* Create a new string from a buffer of ASCII characters.
563563
WARNING: Don't check if the string contains any non-ASCII character. */
564564
PyAPI_FUNC(PyObject*) _PyUnicode_FromASCII(
565-
const char *buffer,
565+
const char *str,
566566
Py_ssize_t size);
567567

568568
/* Compute the maximum character of the substring unicode[start:end].
@@ -629,8 +629,7 @@ typedef struct {
629629
* By default, the minimum buffer size is 0 character and overallocation is
630630
* disabled. Set min_length, min_char and overallocate attributes to control
631631
* the allocation of the buffer. */
632-
PyAPI_FUNC(void)
633-
_PyUnicodeWriter_Init(_PyUnicodeWriter *writer);
632+
PyAPI_FUNC(void) _PyUnicodeWriter_Init(_PyUnicodeWriter *writer);
634633

635634
/* Prepare the buffer to write 'length' characters
636635
with the specified maximum character.
@@ -646,9 +645,11 @@ _PyUnicodeWriter_Init(_PyUnicodeWriter *writer);
646645

647646
/* Don't call this function directly, use the _PyUnicodeWriter_Prepare() macro
648647
instead. */
649-
PyAPI_FUNC(int)
650-
_PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
651-
Py_ssize_t length, Py_UCS4 maxchar);
648+
PyAPI_FUNC(int) _PyUnicodeWriter_PrepareInternal(
649+
_PyUnicodeWriter *writer,
650+
Py_ssize_t length,
651+
Py_UCS4 maxchar
652+
);
652653

653654
/* Prepare the buffer to have at least the kind KIND.
654655
For example, kind=PyUnicode_2BYTE_KIND ensures that the writer will
@@ -663,58 +664,61 @@ _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
663664

664665
/* Don't call this function directly, use the _PyUnicodeWriter_PrepareKind()
665666
macro instead. */
666-
PyAPI_FUNC(int)
667-
_PyUnicodeWriter_PrepareKindInternal(_PyUnicodeWriter *writer,
668-
enum PyUnicode_Kind kind);
667+
PyAPI_FUNC(int) _PyUnicodeWriter_PrepareKindInternal(
668+
_PyUnicodeWriter *writer,
669+
enum PyUnicode_Kind kind
670+
);
669671

670672
/* Append a Unicode character.
671673
Return 0 on success, raise an exception and return -1 on error. */
672-
PyAPI_FUNC(int)
673-
_PyUnicodeWriter_WriteChar(_PyUnicodeWriter *writer,
674+
PyAPI_FUNC(int) _PyUnicodeWriter_WriteChar(
675+
_PyUnicodeWriter *writer,
674676
Py_UCS4 ch
675677
);
676678

677679
/* Append a Unicode string.
678680
Return 0 on success, raise an exception and return -1 on error. */
679-
PyAPI_FUNC(int)
680-
_PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer,
681-
PyObject *str /* Unicode string */
681+
PyAPI_FUNC(int) _PyUnicodeWriter_WriteStr(
682+
_PyUnicodeWriter *writer,
683+
PyObject *unicode /* Unicode string */
682684
);
683685

684686
/* Append a substring of a Unicode string.
685687
Return 0 on success, raise an exception and return -1 on error. */
686-
PyAPI_FUNC(int)
687-
_PyUnicodeWriter_WriteSubstring(_PyUnicodeWriter *writer,
688-
PyObject *str, /* Unicode string */
688+
PyAPI_FUNC(int) _PyUnicodeWriter_WriteSubstring(
689+
_PyUnicodeWriter *writer,
690+
PyObject *unicode, /* Unicode string */
689691
Py_ssize_t start,
690692
Py_ssize_t end
691693
);
692694

693695
/* Append an ASCII-encoded byte string.
694696
Return 0 on success, raise an exception and return -1 on error. */
695-
PyAPI_FUNC(int)
696-
_PyUnicodeWriter_WriteASCIIString(_PyUnicodeWriter *writer,
697+
PyAPI_FUNC(int) _PyUnicodeWriter_WriteASCIIString(
698+
_PyUnicodeWriter *writer,
697699
const char *str, /* ASCII-encoded byte string */
698700
Py_ssize_t len /* number of bytes, or -1 if unknown */
699701
);
700702

701703
/* Append a latin1-encoded byte string.
702704
Return 0 on success, raise an exception and return -1 on error. */
703-
PyAPI_FUNC(int)
704-
_PyUnicodeWriter_WriteLatin1String(_PyUnicodeWriter *writer,
705+
PyAPI_FUNC(int) _PyUnicodeWriter_WriteLatin1String(
706+
_PyUnicodeWriter *writer,
705707
const char *str, /* latin1-encoded byte string */
706708
Py_ssize_t len /* length in bytes */
707709
);
708710

709711
/* Get the value of the writer as a Unicode string. Clear the
710712
buffer of the writer. Raise an exception and return NULL
711713
on error. */
712-
PyAPI_FUNC(PyObject *)
713-
_PyUnicodeWriter_Finish(_PyUnicodeWriter *writer);
714+
PyAPI_FUNC(PyObject *) _PyUnicodeWriter_Finish(
715+
_PyUnicodeWriter *writer
716+
);
714717

715718
/* Deallocate memory of a writer (clear its internal buffer). */
716-
PyAPI_FUNC(void)
717-
_PyUnicodeWriter_Dealloc(_PyUnicodeWriter *writer);
719+
PyAPI_FUNC(void) _PyUnicodeWriter_Dealloc(
720+
_PyUnicodeWriter *writer
721+
);
718722

719723

720724
/* Format the object based on the format_spec, as defined in PEP 3101
@@ -724,12 +728,13 @@ PyAPI_FUNC(int) _PyUnicode_FormatAdvancedWriter(
724728
PyObject *obj,
725729
PyObject *format_spec,
726730
Py_ssize_t start,
727-
Py_ssize_t end);
731+
Py_ssize_t end
732+
);
728733

729734
/* --- wchar_t support for platforms which support it --------------------- */
730735

731736
#ifdef HAVE_WCHAR_H
732-
PyAPI_FUNC(void*) _PyUnicode_AsKind(PyObject *s, unsigned int kind);
737+
PyAPI_FUNC(void*) _PyUnicode_AsKind(PyObject *unicode, unsigned int kind);
733738
#endif
734739

735740
/* --- Manage the default encoding ---------------------------------------- */
@@ -756,7 +761,8 @@ PyAPI_FUNC(void*) _PyUnicode_AsKind(PyObject *s, unsigned int kind);
756761

757762
PyAPI_FUNC(const char *) PyUnicode_AsUTF8AndSize(
758763
PyObject *unicode,
759-
Py_ssize_t *size);
764+
Py_ssize_t *size
765+
);
760766

761767
#define _PyUnicode_AsStringAndSize PyUnicode_AsUTF8AndSize
762768

@@ -816,7 +822,8 @@ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF7(
816822

817823
PyAPI_FUNC(PyObject*) _PyUnicode_AsUTF8String(
818824
PyObject *unicode,
819-
const char *errors);
825+
const char *errors
826+
);
820827

821828
Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
822829
const Py_UNICODE *data, /* Unicode char buffer */
@@ -834,7 +841,7 @@ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32(
834841
);
835842

836843
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32(
837-
PyObject *object, /* Unicode object */
844+
PyObject *unicode, /* Unicode object */
838845
const char *errors, /* error handling */
839846
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
840847
);
@@ -868,7 +875,7 @@ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16(
868875
);
869876

870877
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16(
871-
PyObject* unicode, /* Unicode object */
878+
PyObject *unicode, /* Unicode object */
872879
const char *errors, /* error handling */
873880
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
874881
);
@@ -878,7 +885,7 @@ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16(
878885
/* Helper for PyUnicode_DecodeUnicodeEscape that detects invalid escape
879886
chars. */
880887
PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscape(
881-
const char *string, /* Unicode-Escape encoded string */
888+
const char *str, /* Unicode-Escape encoded string */
882889
Py_ssize_t length, /* size of string */
883890
const char *errors, /* error handling */
884891
const char **first_invalid_escape /* on return, points to first
@@ -952,7 +959,7 @@ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeCharmap(
952959
Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap(
953960
const Py_UNICODE *data, /* Unicode char buffer */
954961
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
955-
PyObject *table, /* Translate table */
962+
PyObject *mapping, /* Translate table */
956963
const char *errors /* error handling */
957964
);
958965

@@ -1005,7 +1012,7 @@ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS(
10051012

10061013
/* Py_DEPRECATED(3.3) */
10071014
PyAPI_FUNC(PyObject*) PyUnicode_TransformDecimalToASCII(
1008-
Py_UNICODE *s, /* Unicode buffer */
1015+
Py_UNICODE *str, /* Unicode buffer */
10091016
Py_ssize_t length /* Number of Py_UNICODE chars to transform */
10101017
);
10111018

@@ -1040,8 +1047,8 @@ PyAPI_FUNC(int) _PyUnicode_EqualToASCIIId(
10401047
0 otherwise. The right argument must be ASCII-encoded string.
10411048
Any error occurs inside will be cleared before return. */
10421049
PyAPI_FUNC(int) _PyUnicode_EqualToASCIIString(
1043-
PyObject *left,
1044-
const char *right /* ASCII-encoded string */
1050+
PyObject *unicode,
1051+
const char *str /* ASCII-encoded string */
10451052
);
10461053

10471054
/* Externally visible for str.strip(unicode) */
@@ -1063,7 +1070,8 @@ PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGrouping(
10631070
Py_ssize_t min_width,
10641071
const char *grouping,
10651072
PyObject *thousands_sep,
1066-
Py_UCS4 *maxchar);
1073+
Py_UCS4 *maxchar
1074+
);
10671075

10681076
/* === Characters Type APIs =============================================== */
10691077

@@ -1215,7 +1223,12 @@ Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strrchr(
12151223
Py_UNICODE c
12161224
);
12171225

1218-
PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int);
1226+
PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(
1227+
PyObject *val,
1228+
int alt,
1229+
int prec,
1230+
int type
1231+
);
12191232

12201233
/* Create a copy of a unicode string ending with a nul character. Return NULL
12211234
and raise a MemoryError exception on memory allocation failure, otherwise
@@ -1226,13 +1239,16 @@ Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy(
12261239
);
12271240

12281241
/* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/
1229-
PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);
1242+
PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier *id);
12301243
/* Clear all static strings. */
12311244
PyAPI_FUNC(void) _PyUnicode_ClearStaticStrings(void);
12321245

12331246
/* Fast equality check when the inputs are known to be exact unicode types
12341247
and where the hash values are equal (i.e. a very probable match) */
1235-
PyAPI_FUNC(int) _PyUnicode_EQ(PyObject *, PyObject *);
1248+
PyAPI_FUNC(int) _PyUnicode_EQ(
1249+
PyObject *left,
1250+
PyObject *right
1251+
);
12361252

12371253
#ifdef __cplusplus
12381254
}

Include/internal/pycore_fileutils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ extern "C" {
1313
PyAPI_DATA(int) _Py_HasFileSystemDefaultEncodeErrors;
1414

1515
PyAPI_FUNC(int) _Py_DecodeUTF8Ex(
16-
const char *arg,
17-
Py_ssize_t arglen,
16+
const char *str,
17+
Py_ssize_t size,
1818
wchar_t **wstr,
1919
size_t *wlen,
2020
const char **reason,

0 commit comments

Comments
 (0)