Skip to content

Commit 3c4844f

Browse files
committed
Add constant
1 parent 4ccd7d9 commit 3c4844f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Objects/unicodeobject.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ NOTE: In the interpreter's initialization phase, some globals are currently
189189
# define OVERALLOCATE_FACTOR 4
190190
#endif
191191

192+
#define EMBED_NULL_UNKNOWN 2
193+
192194
/* Forward declaration */
193195
static inline int
194196
_PyUnicodeWriter_WriteCharInline(_PyUnicodeWriter *writer, Py_UCS4 ch);
@@ -628,7 +630,7 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
628630
CHECK(PyUnicode_READ(kind, data, ascii->length) == 0);
629631
}
630632

631-
if (_PyUnicode_STATE(ascii).embed_null != 2) {
633+
if (_PyUnicode_STATE(ascii).embed_null != EMBED_NULL_UNKNOWN) {
632634
Py_ssize_t pos = findchar(PyUnicode_DATA(ascii),
633635
PyUnicode_KIND(ascii),
634636
PyUnicode_GET_LENGTH(ascii),
@@ -1266,7 +1268,7 @@ PyUnicode_New(Py_ssize_t size, Py_UCS4 maxchar)
12661268
_PyUnicode_STATE(unicode).compact = 1;
12671269
_PyUnicode_STATE(unicode).ascii = is_ascii;
12681270
_PyUnicode_STATE(unicode).statically_allocated = 0;
1269-
_PyUnicode_STATE(unicode).embed_null = 2;
1271+
_PyUnicode_STATE(unicode).embed_null = EMBED_NULL_UNKNOWN;
12701272
if (is_ascii) {
12711273
((char*)data)[size] = 0;
12721274
}
@@ -3876,7 +3878,7 @@ PyUnicode_AsUTF8(PyObject *unicode)
38763878

38773879
// Cache to avoid calling O(n) strlen() operation at every
38783880
// PyUnicode_AsUTF8() call on the same object.
3879-
if (_PyUnicode_STATE(unicode).embed_null == 2) {
3881+
if (_PyUnicode_STATE(unicode).embed_null == EMBED_NULL_UNKNOWN) {
38803882
if (strlen(utf8) != (size_t)size) {
38813883
_PyUnicode_STATE(unicode).embed_null = 1;
38823884
}
@@ -14668,7 +14670,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject *unicode)
1466814670
_PyUnicode_STATE(self).compact = 0;
1466914671
_PyUnicode_STATE(self).ascii = _PyUnicode_STATE(unicode).ascii;
1467014672
_PyUnicode_STATE(self).statically_allocated = 0;
14671-
_PyUnicode_STATE(self).embed_null = 2;
14673+
_PyUnicode_STATE(self).embed_null = EMBED_NULL_UNKNOWN;
1467214674
_PyUnicode_UTF8_LENGTH(self) = 0;
1467314675
_PyUnicode_UTF8(self) = NULL;
1467414676
_PyUnicode_DATA_ANY(self) = NULL;

0 commit comments

Comments
 (0)