Author vstinner
Recipients christian.heimes, corona10, petr.viktorin, shihai1991, vstinner
Date 2020-05-18.13:07:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1589807240.02.0.725265164424.issue40671@roundup.psfhosted.org>
In-reply-to
Content
In Modules/_hashopenssl.c:PyInit__hashlib(), PyModule_AddObject() can be replaced with PyModule_AddType() to add the 3 types: this function does the Py_INCREF for us, which reduces errors if the function fails.

The results of other PyModule_AddObject() calls should also be checked to handle errors.

The following _hashlibstate_global macro is no longer used:

#define _hashlibstate_global ((_hashlibstate *)PyModule_GetState(PyState_FindModule(&_hashlibmodule)))

EVPnew() got a module parameter, so it doesn't need _hashlibstate_global anymore.

Dong-hee, Hai: Maybe it's time to convert this module to PEP 489 multiphase initialization?

Hai: do you want to work on a PR?

--

Question: do EVPobject and HMACobject rely on a global state somewhere in OpenSSL? Or is it safe to use them in subinterpreters, with multiple instances of _hashlib?

EVPobject and HMACobject have "lock" member.

Even if converting the module to PEP 489 is not enough to make it compatible with subinterpreters (I don't know, maybe it's enought, see my question), it should help for that :-)

Note: the current code is already quite clean, I like it :-)

cc Petr & Christian.
History
Date User Action Args
2020-05-18 13:07:20vstinnersetrecipients: + vstinner, christian.heimes, petr.viktorin, corona10, shihai1991
2020-05-18 13:07:20vstinnersetmessageid: <1589807240.02.0.725265164424.issue40671@roundup.psfhosted.org>
2020-05-18 13:07:19vstinnerlinkissue40671 messages
2020-05-18 13:07:19vstinnercreate