summaryrefslogtreecommitdiff
path: root/Include/unicodeobject.h
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-11-16 15:40:39 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-11-16 15:40:39 +0200
commitf5894dd646f5e39918377b37b8c8694cebdca103 (patch)
tree7332d366d9a5888ac6c5b8b15f0c1d6ea7bf2481 /Include/unicodeobject.h
parentf4934ea77da38516731a75fbf9458b248d26dd81 (diff)
downloadcpython-git-f5894dd646f5e39918377b37b8c8694cebdca103.tar.gz
Issue #28701: Replace _PyUnicode_CompareWithId with _PyUnicode_EqualToASCIIId.
The latter function is more readable, faster and doesn't raise exceptions. Based on patch by Xiang Zhang.
Diffstat (limited to 'Include/unicodeobject.h')
-rw-r--r--Include/unicodeobject.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index 007c15bd47..6b6acd7353 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -2000,12 +2000,31 @@ PyAPI_FUNC(int) PyUnicode_Compare(
);
#ifndef Py_LIMITED_API
+/* Compare a string with an identifier and return -1, 0, 1 for less than,
+ equal, and greater than, respectively.
+ Raise an exception and return -1 on error. */
+
PyAPI_FUNC(int) _PyUnicode_CompareWithId(
PyObject *left, /* Left string */
_Py_Identifier *right /* Right identifier */
);
+
+/* Test whether a unicode is equal to ASCII identifier. Return 1 if true,
+ 0 otherwise. Return 0 if any argument contains non-ASCII characters.
+ Any error occurs inside will be cleared before return. */
+
+PyAPI_FUNC(int) _PyUnicode_EqualToASCIIId(
+ PyObject *left, /* Left string */
+ _Py_Identifier *right /* Right identifier */
+ );
#endif
+/* Compare a Unicode object with C string and return -1, 0, 1 for less than,
+ equal, and greater than, respectively. It is best to pass only
+ ASCII-encoded strings, but the function interprets the input string as
+ ISO-8859-1 if it contains non-ASCII characters.
+ Raise an exception and return -1 on error. */
+
PyAPI_FUNC(int) PyUnicode_CompareWithASCIIString(
PyObject *left,
const char *right /* ASCII-encoded string */