summaryrefslogtreecommitdiffstats
path: root/Objects/setobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-03-31 07:59:27 (GMT)
committerGitHub <noreply@github.com>2022-03-31 07:59:27 (GMT)
commitc14d7e4b816134b8e93ece4066a86d229631ce96 (patch)
tree6b2ac5b9c3e502d77d1ff05bdcc88e918dba1ad4 /Objects/setobject.c
parentdb4dada5108dd49ebca23e4559a53630a2df8447 (diff)
downloadcpython-c14d7e4b816134b8e93ece4066a86d229631ce96.zip
cpython-c14d7e4b816134b8e93ece4066a86d229631ce96.tar.gz
cpython-c14d7e4b816134b8e93ece4066a86d229631ce96.tar.bz2
bpo-47164: Add _PyASCIIObject_CAST() macro (GH-32191)
Add macros to cast objects to PyASCIIObject*, PyCompactUnicodeObject* and PyUnicodeObject*: _PyASCIIObject_CAST(), _PyCompactUnicodeObject_CAST() and _PyUnicodeObject_CAST(). Using these new macros make the code more readable and check their argument with: assert(PyUnicode_Check(op)). Remove redundant assert(PyUnicode_Check(op)) in macros using directly or indirectly these new CAST macros. Replacing existing casts with these macros.
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r--Objects/setobject.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c
index c65b7d5..022ae8e 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -346,7 +346,7 @@ set_add_key(PySetObject *so, PyObject *key)
Py_hash_t hash;
if (!PyUnicode_CheckExact(key) ||
- (hash = ((PyASCIIObject *) key)->hash) == -1) {
+ (hash = _PyASCIIObject_CAST(key)->hash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return -1;
@@ -360,7 +360,7 @@ set_contains_key(PySetObject *so, PyObject *key)
Py_hash_t hash;
if (!PyUnicode_CheckExact(key) ||
- (hash = ((PyASCIIObject *) key)->hash) == -1) {
+ (hash = _PyASCIIObject_CAST(key)->hash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return -1;
@@ -374,7 +374,7 @@ set_discard_key(PySetObject *so, PyObject *key)
Py_hash_t hash;
if (!PyUnicode_CheckExact(key) ||
- (hash = ((PyASCIIObject *) key)->hash) == -1) {
+ (hash = _PyASCIIObject_CAST(key)->hash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return -1;