X Tutup
Skip to content

Commit bcde10a

Browse files
Issue python#26765: Ensure that bytes- and unicode-specific stringlib files are used
with correct type.
1 parent cbcc2fd commit bcde10a

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

Objects/stringlib/codecs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* stringlib: codec implementations */
22

3-
#if STRINGLIB_IS_UNICODE
3+
#if !STRINGLIB_IS_UNICODE
4+
# error "codecs.h is specific to Unicode"
5+
#endif
46

57
/* Mask to quickly check whether a C 'long' contains a
68
non-ASCII, UTF8-encoded char. */
@@ -823,5 +825,3 @@ STRINGLIB(utf32_encode)(const STRINGLIB_CHAR *in,
823825
#undef SWAB4
824826

825827
#endif
826-
827-
#endif /* STRINGLIB_IS_UNICODE */

Objects/stringlib/ctype.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/* NOTE: this API is -ONLY- for use with single byte character strings. */
2-
/* Do not use it with Unicode. */
1+
#if STRINGLIB_IS_UNICODE
2+
# error "ctype.h only compatible with byte-wise strings"
3+
#endif
34

45
#include "bytes_methods.h"
56

Objects/stringlib/find_max_char.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* Finding the optimal width of unicode characters in a buffer */
22

3-
#if STRINGLIB_IS_UNICODE
3+
#if !STRINGLIB_IS_UNICODE
4+
# error "find_max_char.h is specific to Unicode"
5+
#endif
46

57
/* Mask to quickly check whether a C 'long' contains a
68
non-ASCII, UTF8-encoded char. */
@@ -129,5 +131,4 @@ STRINGLIB(find_max_char)(const STRINGLIB_CHAR *begin, const STRINGLIB_CHAR *end)
129131
#undef MAX_CHAR_UCS4
130132

131133
#endif /* STRINGLIB_SIZEOF_CHAR == 1 */
132-
#endif /* STRINGLIB_IS_UNICODE */
133134

Objects/stringlib/join.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* stringlib: bytes joining implementation */
22

3-
#if STRINGLIB_SIZEOF_CHAR != 1
3+
#if STRINGLIB_IS_UNICODE
44
#error join.h only compatible with byte-wise strings
55
#endif
66

Objects/stringlib/localeutil.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include <locale.h>
44

5-
#ifndef STRINGLIB_IS_UNICODE
6-
# error "localeutil is specific to Unicode"
5+
#if !STRINGLIB_IS_UNICODE
6+
# error "localeutil.h is specific to Unicode"
77
#endif
88

99
typedef struct {

Objects/stringlib/transmogrify.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/* NOTE: this API is -ONLY- for use with single byte character strings. */
2-
/* Do not use it with Unicode. */
1+
#if STRINGLIB_IS_UNICODE
2+
# error "transmogrify.h only compatible with byte-wise strings"
3+
#endif
34

45
/* the more complicated methods. parts of these should be pulled out into the
56
shared code in bytes_methods.c to cut down on duplicate code bloat. */

0 commit comments

Comments
 (0)
X Tutup