[issue33528] os.getentropy support

Christian Heimes report at bugs.python.org
Sat May 19 12:26:42 EDT 2018


Christian Heimes <lists at cheimes.de> added the comment:

I'm -1 on this feature.

It's both confusing and unnecessary to have this feature in the standard library. In general we prefer portable functions or expose platform-specific functions for unique features. The getentropy function is neither portable nor more useful than the high-level wrapper os.urandom().

If you truly require to access the raw function, then you can easily access the libc function with a simple C-types wrapper:

>>> from ctypes import cdll, create_string_buffer
>>> libc = cdll.LoadLibrary("libc.so.6") 
>>> buf = create_string_buffer(8)
>>> buf.raw
b'\x00\x00\x00\x00\x00\x00\x00\x00'
>>> libc.getentropy(buf, len(buf))
0
>>> buf.raw
b'\xd9\x83`\x8a\x89\xc7\x9eX'

----------
nosy: +christian.heimes

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


More information about the Python-bugs-list mailing list