>>> import unicodedata
>>> unicodedata.lookup(b'SNAKE') # `lookup` happens to use the s# format internally
'🐍'
>>> view = memoryview(b'SNAKE')
>>> view.readonly
True
>>> unicodedata.lookup(view)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: lookup() argument must be read-only bytes-like object, not memoryview
The docs should explain the semantics precisely, without overwhelming the user that just wants to take str/bytes.
The docs say:
This can easily be understood that
bf_releasebufferis directly linked to (im)mutability.In reality this check is there to ensure whether the buffer can be safely "borrowed". For simple buffer exporters (like most of the stdlib ones), this correlates with immutability -- but not always, e.g.:
The docs should explain the semantics precisely, without overwhelming the user that just wants to take
str/bytes.Linked PRs