[issue45150] Add a file_digest() function in hashlib

Aur Saraf report at bugs.python.org
Tue Mar 15 22:36:04 EDT 2022


Aur Saraf <sonoflilit at gmail.com> added the comment:

Forgot an important warning: this is the first time I write C code against the Python API, and I didn't thoroughly read the guide (or at all, to be honest). I think I did a good job, but please suspect my code of noob errors.

I'm especially not confident that it's OK to not do any special handling of signals. Can read() return 0 if it was interrupted by a signal? This will stop the hash calculation midway and behave as if it succeeded. Sounds suspiciously like something we don't want. Also, I probably should support signals because such a long operation is something the user definitely might want to interrupt?

May I have some guidance please? Would it be enough to copy the code from fileutils.c _Py_Read() and addi an outer loop so we can do many reads with the GIL released and still call PyErr_CheckSignals when needed with the GIL taken?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45150>
_______________________________________


More information about the Python-bugs-list mailing list