Use get_binascii_state instead of PyModule_GetState (GH-26069)

This commit is contained in:
Dong-hee Na 2021-05-13 00:09:30 +09:00 committed by GitHub
parent 2b458c1dba
commit 9b06e4b535
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 13 deletions

View File

@ -66,7 +66,7 @@ typedef struct binascii_state {
PyObject *Incomplete;
} binascii_state;
static binascii_state *
static inline binascii_state *
get_binascii_state(PyObject *module)
{
return (binascii_state *)PyModule_GetState(module);
@ -312,7 +312,7 @@ binascii_a2b_uu_impl(PyObject *module, Py_buffer *data)
** '`' as zero instead of space.
*/
if ( this_ch < ' ' || this_ch > (' ' + 64)) {
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL) {
return NULL;
}
@ -344,7 +344,7 @@ binascii_a2b_uu_impl(PyObject *module, Py_buffer *data)
/* Extra '`' may be written as padding in some cases */
if ( this_ch != ' ' && this_ch != ' '+64 &&
this_ch != '\n' && this_ch != '\r' ) {
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL) {
return NULL;
}
@ -385,7 +385,7 @@ binascii_b2a_uu_impl(PyObject *module, Py_buffer *data, int backtick)
bin_len = data->len;
if ( bin_len > 45 ) {
/* The 45 is a limit that appears in all uuencode's */
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL) {
return NULL;
}
@ -505,9 +505,9 @@ binascii_a2b_base64_impl(PyObject *module, Py_buffer *data)
}
if (quad_pos != 0) {
binascii_state *state = PyModule_GetState(module);
binascii_state *state = get_binascii_state(module);
if (state == NULL) {
/* error already set, from PyModule_GetState */
/* error already set, from get_binascii_state */
} else if (quad_pos == 1) {
/*
** There is exactly one extra valid, non-padding, base64 character.
@ -562,7 +562,7 @@ binascii_b2a_base64_impl(PyObject *module, Py_buffer *data, int newline)
assert(bin_len >= 0);
if ( bin_len > BASE64_MAXBIN ) {
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL) {
return NULL;
}
@ -657,7 +657,7 @@ binascii_a2b_hqx_impl(PyObject *module, Py_buffer *data)
if ( this_ch == SKIP )
continue;
if ( this_ch == FAIL ) {
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL) {
return NULL;
}
@ -682,7 +682,7 @@ binascii_a2b_hqx_impl(PyObject *module, Py_buffer *data)
}
if ( leftbits && !done ) {
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL) {
return NULL;
}
@ -878,7 +878,7 @@ binascii_rledecode_hqx_impl(PyObject *module, Py_buffer *data)
#define INBYTE(b) \
do { \
if ( --in_len < 0 ) { \
state = PyModule_GetState(module); \
state = get_binascii_state(module); \
if (state == NULL) { \
return NULL; \
} \
@ -904,7 +904,7 @@ binascii_rledecode_hqx_impl(PyObject *module, Py_buffer *data)
/* Note Error, not Incomplete (which is at the end
** of the string only). This is a programmer error.
*/
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL) {
return NULL;
}
@ -1235,7 +1235,7 @@ binascii_a2b_hex_impl(PyObject *module, Py_buffer *hexstr)
* raise an exception.
*/
if (arglen % 2) {
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL) {
return NULL;
}
@ -1252,7 +1252,7 @@ binascii_a2b_hex_impl(PyObject *module, Py_buffer *hexstr)
unsigned int top = _PyLong_DigitValue[Py_CHARMASK(argbuf[i])];
unsigned int bot = _PyLong_DigitValue[Py_CHARMASK(argbuf[i+1])];
if (top >= 16 || bot >= 16) {
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL) {
return NULL;
}