diff options
author | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2004-03-11 01:00:44 (GMT) |
---|---|---|
committer | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2004-03-11 01:00:44 (GMT) |
commit | 0eadcd9cbbc3e165f046fa01025e2a76084a8e52 (patch) | |
tree | 0ef2dd9ac88773102af7efeaa3f3452e214711ce /Objects/bufferobject.c | |
parent | 5e3a675b6d0f257a4fbd1484f0dc7cd1d20c6b22 (diff) | |
download | cpython-0eadcd9cbbc3e165f046fa01025e2a76084a8e52.zip cpython-0eadcd9cbbc3e165f046fa01025e2a76084a8e52.tar.gz cpython-0eadcd9cbbc3e165f046fa01025e2a76084a8e52.tar.bz2 |
Document one of the many problems with the buffer object.
Diffstat (limited to 'Objects/bufferobject.c')
-rw-r--r-- | Objects/bufferobject.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Objects/bufferobject.c b/Objects/bufferobject.c index fe2be73..561d6c1 100644 --- a/Objects/bufferobject.c +++ b/Objects/bufferobject.c @@ -228,10 +228,17 @@ buffer_hash(PyBufferObject *self) if ( self->b_hash != -1 ) return self->b_hash; + /* XXX potential bugs here, a readonly buffer does not imply that the + * underlying memory is immutable. b_readonly is a necessary but not + * sufficient condition for a buffer to be hashable. Perhaps it would + * be better to only allow hashing if the underlying object is known to + * be immutable (e.g. PyString_Check() is true). Another idea would + * be to call tp_hash on the underlying object and see if it raises + * an error. */ if ( !self->b_readonly ) { - /* ### use different wording, since this is conditional? */ - PyErr_SetString(PyExc_TypeError, "unhashable type"); + PyErr_SetString(PyExc_TypeError, + "writable buffers are not hashable"); return -1; } |