Skip to content

Commit 9a27a3e

Browse files
changes as per code comments
1 parent 59de33a commit 9a27a3e

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

Objects/bytesobject.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "pycore_object.h" // _PyObject_GC_TRACK
1414
#include "pycore_pymem.h" // PYMEM_CLEANBYTE
1515
#include "pycore_strhex.h" // _Py_strhex_with_sep()
16-
#include "pycore_pyatomic_ft_wrappers.h"
1716

1817
#include <stddef.h>
1918

@@ -126,10 +125,7 @@ _PyBytes_FromSize(Py_ssize_t size, int use_calloc)
126125
return PyErr_NoMemory();
127126
}
128127
_PyObject_InitVar((PyVarObject*)op, &PyBytes_Type, size);
129-
_Py_COMP_DIAG_PUSH
130-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
131128
set_ob_shash(op, -1);
132-
_Py_COMP_DIAG_POP
133129
if (!use_calloc) {
134130
op->ob_sval[size] = '\0';
135131
}
@@ -193,10 +189,7 @@ PyBytes_FromString(const char *str)
193189
return PyErr_NoMemory();
194190
}
195191
_PyObject_InitVar((PyVarObject*)op, &PyBytes_Type, size);
196-
_Py_COMP_DIAG_PUSH
197-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
198192
set_ob_shash(op, -1);
199-
_Py_COMP_DIAG_POP
200193
memcpy(op->ob_sval, str, size+1);
201194
return (PyObject *) op;
202195
}
@@ -1513,10 +1506,7 @@ bytes_repeat(PyObject *self, Py_ssize_t n)
15131506
return PyErr_NoMemory();
15141507
}
15151508
_PyObject_InitVar((PyVarObject*)op, &PyBytes_Type, size);
1516-
_Py_COMP_DIAG_PUSH
1517-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
15181509
set_ob_shash(op, -1);
1519-
_Py_COMP_DIAG_POP
15201510
op->ob_sval[size] = '\0';
15211511

15221512
_PyBytes_Repeat(op->ob_sval, size, a->ob_sval, Py_SIZE(a));
@@ -1625,16 +1615,13 @@ static Py_hash_t
16251615
bytes_hash(PyObject *self)
16261616
{
16271617
PyBytesObject *a = _PyBytes_CAST(self);
1628-
_Py_COMP_DIAG_PUSH
1629-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
16301618
Py_hash_t hash = get_ob_shash(a);
16311619
if (hash == -1) {
16321620
/* Can't fail */
16331621
hash = Py_HashBuffer(a->ob_sval, Py_SIZE(a));
16341622
set_ob_shash(a, hash);
16351623
}
1636-
return hash;
1637-
_Py_COMP_DIAG_POP
1624+
return get_ob_shash(a);
16381625
}
16391626

16401627
static PyObject*
@@ -3034,10 +3021,7 @@ bytes_alloc(PyTypeObject *self, Py_ssize_t nitems)
30343021
if (obj == NULL) {
30353022
return NULL;
30363023
}
3037-
_Py_COMP_DIAG_PUSH
3038-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
30393024
set_ob_shash(obj, -1);
3040-
_Py_COMP_DIAG_POP
30413025
return (PyObject*)obj;
30423026
}
30433027

@@ -3054,11 +3038,8 @@ bytes_subtype_new(PyTypeObject *type, PyObject *tmp)
30543038
if (pnew != NULL) {
30553039
memcpy(PyBytes_AS_STRING(pnew),
30563040
PyBytes_AS_STRING(tmp), n+1);
3057-
_Py_COMP_DIAG_PUSH
3058-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
30593041
set_ob_shash((PyBytesObject *)pnew,
30603042
get_ob_shash((PyBytesObject *)tmp));
3061-
_Py_COMP_DIAG_POP
30623043
}
30633044
return pnew;
30643045
}
@@ -3251,10 +3232,7 @@ _PyBytes_Resize(PyObject **pv, Py_ssize_t newsize)
32513232
sv = (PyBytesObject *) *pv;
32523233
Py_SET_SIZE(sv, newsize);
32533234
sv->ob_sval[newsize] = '\0';
3254-
_Py_COMP_DIAG_PUSH
3255-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
32563235
set_ob_shash(sv, -1); /* invalidate cached hash value */
3257-
_Py_COMP_DIAG_POP
32583236
return 0;
32593237
}
32603238

0 commit comments

Comments
 (0)