Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-36346: Prepare for removing the legacy Unicode C API. #12409

Closed
Closed
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
699e616
bpo-36346: Prepare for removing the legacy Unicode C API.
serhiy-storchaka Oct 26, 2018
60b89c9
Fix winreg.SetValue().
serhiy-storchaka Mar 19, 2019
f386b63
Clean up some ifdefs in _testcapimodule.
serhiy-storchaka Mar 19, 2019
11e0e0c
Make path_cleanup() paranoidally safer.
serhiy-storchaka Mar 19, 2019
236f608
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Mar 19, 2019
8750d48
Fix os.scandir().
serhiy-storchaka Mar 20, 2019
431e71f
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Mar 20, 2019
545c7a9
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Mar 28, 2019
3c1ab31
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Mar 13, 2020
54b0561
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Jun 15, 2020
2c62d96
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Jun 29, 2020
6d89775
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Jun 30, 2020
3b5294a
Silence compiler warnings.
serhiy-storchaka Jun 30, 2020
e7898fa
Fix PyUnicode_IsIdentifier for the cache-less build.
serhiy-storchaka Jun 30, 2020
fd641c6
Silence compiler warnings on Windows.
serhiy-storchaka Jun 30, 2020
a79d935
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Jun 30, 2020
ed14aa9
Fix compiler warning in _testcapi.
serhiy-storchaka Jun 30, 2020
c5eb102
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Jul 1, 2020
d529224
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Jul 1, 2020
6102b4b
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Jul 5, 2020
74695b3
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Jul 5, 2020
97b5228
Use HAVE_UNICODE_WCHAR_CACHE instead of USE_UNICODE_WCHAR_CACHE in _P…
serhiy-storchaka Jul 5, 2020
d6ba6b7
Set HAVE_UNICODE_WCHAR_CACHE and USE_UNICODE_WCHAR_CACHE only if they…
serhiy-storchaka Jul 9, 2020
0da4146
Remove Py_UNICODE_MATCH.
serhiy-storchaka Jul 9, 2020
51365fb
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Jul 10, 2020
e425908
Fix unterminated #if.
serhiy-storchaka Jul 10, 2020
8a9259b
Reset arraymodule.c.
serhiy-storchaka Jul 10, 2020
76ba4b6
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Jul 10, 2020
16ac7fd
Temporary disable the wchar_t cache by default.
serhiy-storchaka Jul 10, 2020
5e90bf8
Fix unicode_result().
serhiy-storchaka Jul 10, 2020
09675ab
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Jul 10, 2020
6915ce3
Merge branch 'master' into disable-wchar-cache
serhiy-storchaka Apr 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Include/cpython/unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@

/* --- Internal Unicode Operations ---------------------------------------- */

#ifndef HAVE_UNICODE_WCHAR_CACHE
# define HAVE_UNICODE_WCHAR_CACHE 0
#endif /* HAVE_UNICODE_WCHAR_CACHE */

#ifndef USE_UNICODE_WCHAR_CACHE
# define USE_UNICODE_WCHAR_CACHE 1
# define USE_UNICODE_WCHAR_CACHE HAVE_UNICODE_WCHAR_CACHE
#endif /* USE_UNICODE_WCHAR_CACHE */

/* Since splitting on whitespace is an important use case, and
Expand Down Expand Up @@ -215,7 +219,9 @@ typedef struct {
4 bytes (see issue #19537 on m68k). */
unsigned int :24;
} state;
#if HAVE_UNICODE_WCHAR_CACHE
wchar_t *wstr; /* wchar_t representation (null-terminated) */
#endif /* HAVE_UNICODE_WCHAR_CACHE */
} PyASCIIObject;

/* Non-ASCII strings allocated through PyUnicode_New use the
Expand All @@ -226,8 +232,10 @@ typedef struct {
Py_ssize_t utf8_length; /* Number of bytes in utf8, excluding the
* terminating \0. */
char *utf8; /* UTF-8 representation (null-terminated) */
#if HAVE_UNICODE_WCHAR_CACHE
Py_ssize_t wstr_length; /* Number of code points in wstr, possible
* surrogates count as two code points. */
#endif /* HAVE_UNICODE_WCHAR_CACHE */
} PyCompactUnicodeObject;

/* Strings allocated through PyUnicode_FromUnicode(NULL, len) use the
Expand All @@ -248,6 +256,7 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
int check_content);

/* Fast access macros */
#if HAVE_UNICODE_WCHAR_CACHE

/* Returns the deprecated Py_UNICODE representation's size in code units
(this includes surrogate pairs as 2 units).
Expand Down Expand Up @@ -282,6 +291,7 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
#define PyUnicode_AS_DATA(op) \
((const char *)(PyUnicode_AS_UNICODE(op)))

#endif /* HAVE_UNICODE_WCHAR_CACHE */

/* --- Flexible String Representation Helper Macros (PEP 393) -------------- */

Expand Down Expand Up @@ -442,13 +452,15 @@ enum PyUnicode_Kind {
(0xffffU) : \
(0x10ffffU)))))

#if HAVE_UNICODE_WCHAR_CACHE
Py_DEPRECATED(3.3)
static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
return PyUnicode_IS_COMPACT_ASCII(op) ?
((PyASCIIObject*)op)->length :
((PyCompactUnicodeObject*)op)->wstr_length;
}
#define PyUnicode_WSTR_LENGTH(op) _PyUnicode_get_wstr_length((PyObject*)op)
#endif /* HAVE_UNICODE_WCHAR_CACHE */

/* === Public API ========================================================= */

Expand Down
Loading