[Python-Dev] "buffer interface" messages
On Fri, 03 Dec 2010 10:11:29 -0500 "R. David Murray" wrote: > > > > >>> 'abc'.transform('hex') > > TypeError: 'str' does not support the buffer interface > > >>> b'abc'.transform('rot13') > > TypeError: expected an object with the buffer interface > > I find these 'buffer interface' error messages to be the most confusing > error message I get out of Python3 no matter what context they show up > in. I have no idea what they are telling me. That issue is more > general than transform/untransform, but perhaps it could be fixed > for transform/untransform in particular. I agree. "buffer interface" is a technicality that the Python user doesn't do about (unless (s)he also writes C extensions). How about "expected a bytes-compatible object"? Regards Antoine. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] "buffer interface" messages
On Sat, Dec 4, 2010 at 2:28 AM, Antoine Pitrou wrote: > On Fri, 03 Dec 2010 10:11:29 -0500 > "R. David Murray" wrote: >> > >> > >>> 'abc'.transform('hex') >> > TypeError: 'str' does not support the buffer interface >> > >>> b'abc'.transform('rot13') >> > TypeError: expected an object with the buffer interface >> >> I find these 'buffer interface' error messages to be the most confusing >> error message I get out of Python3 no matter what context they show up >> in. I have no idea what they are telling me. That issue is more >> general than transform/untransform, but perhaps it could be fixed >> for transform/untransform in particular. > > I agree. "buffer interface" is a technicality that the Python user > doesn't do about (unless (s)he also writes C extensions). How about > "expected a bytes-compatible object"? Why not "binary data interface"? That's what they're actually looking for. It seems odd for 'rot13' to be throwing that error though. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] "buffer interface" messages
On Sat, 4 Dec 2010 02:45:42 +1000 Nick Coghlan wrote: > On Sat, Dec 4, 2010 at 2:28 AM, Antoine Pitrou wrote: > > On Fri, 03 Dec 2010 10:11:29 -0500 > > "R. David Murray" wrote: > >> > > >> > >>> 'abc'.transform('hex') > >> > TypeError: 'str' does not support the buffer interface > >> > >>> b'abc'.transform('rot13') > >> > TypeError: expected an object with the buffer interface > >> > >> I find these 'buffer interface' error messages to be the most confusing > >> error message I get out of Python3 no matter what context they show up > >> in. I have no idea what they are telling me. That issue is more > >> general than transform/untransform, but perhaps it could be fixed > >> for transform/untransform in particular. > > > > I agree. "buffer interface" is a technicality that the Python user > > doesn't do about (unless (s)he also writes C extensions). How about > > "expected a bytes-compatible object"? > > Why not "binary data interface"? That's what they're actually looking for. I don't think it's more understandable, since it's not a well-known Python concept. (and in this specific case, the transform() method is on str and bytes, not on arbitrary bytes-like objects) > It seems odd for 'rot13' to be throwing that error though. Agreed. Regards Antoine. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] "buffer interface" messages
On Sat, Dec 4, 2010 at 2:57 AM, Antoine Pitrou wrote: > On Sat, 4 Dec 2010 02:45:42 +1000 > Nick Coghlan wrote: >> On Sat, Dec 4, 2010 at 2:28 AM, Antoine Pitrou wrote: >> > On Fri, 03 Dec 2010 10:11:29 -0500 >> > "R. David Murray" wrote: >> >> > >> >> > >>> 'abc'.transform('hex') >> >> > TypeError: 'str' does not support the buffer interface >> >> > >>> b'abc'.transform('rot13') >> >> > TypeError: expected an object with the buffer interface >> >> >> >> I find these 'buffer interface' error messages to be the most confusing >> >> error message I get out of Python3 no matter what context they show up >> >> in. I have no idea what they are telling me. That issue is more >> >> general than transform/untransform, but perhaps it could be fixed >> >> for transform/untransform in particular. >> > >> > I agree. "buffer interface" is a technicality that the Python user >> > doesn't do about (unless (s)he also writes C extensions). How about >> > "expected a bytes-compatible object"? >> >> Why not "binary data interface"? That's what they're actually looking for. > > I don't think it's more understandable, since it's not a well-known > Python concept. > (and in this specific case, the transform() method is on str and bytes, > not on arbitrary bytes-like objects) Indeed, "bytes-compatible" is likely to be the most meaningful phrase (and then we can have the bytes docs explain further as to what "bytes-compatible" means, likely by reference to memoryview). Although, as Victor's mod to the complex constructor error message shows, the default error message is still going to be overly specific in many cases that also accept non-binary data. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] "buffer interface" messages
Am 03.12.2010 17:57, schrieb Antoine Pitrou: > On Sat, 4 Dec 2010 02:45:42 +1000 > Nick Coghlan wrote: >> On Sat, Dec 4, 2010 at 2:28 AM, Antoine Pitrou wrote: >> > On Fri, 03 Dec 2010 10:11:29 -0500 >> > "R. David Murray" wrote: >> >> > >> >> > >>> 'abc'.transform('hex') >> >> > TypeError: 'str' does not support the buffer interface >> >> > >>> b'abc'.transform('rot13') >> >> > TypeError: expected an object with the buffer interface >> >> >> >> I find these 'buffer interface' error messages to be the most confusing >> >> error message I get out of Python3 no matter what context they show up >> >> in. I have no idea what they are telling me. That issue is more >> >> general than transform/untransform, but perhaps it could be fixed >> >> for transform/untransform in particular. >> > >> > I agree. "buffer interface" is a technicality that the Python user >> > doesn't do about (unless (s)he also writes C extensions). How about >> > "expected a bytes-compatible object"? >> >> Why not "binary data interface"? That's what they're actually looking for. > > I don't think it's more understandable, since it's not a well-known > Python concept. > (and in this specific case, the transform() method is on str and bytes, > not on arbitrary bytes-like objects) "object that can be handled as bytes"? "object that provides bytes"? >> It seems odd for 'rot13' to be throwing that error though. > > Agreed. rot13 is a str<->str codec. Georg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] "buffer interface" messages
On Fri, 03 Dec 2010 18:09:39 +0100 Georg Brandl wrote: > Am 03.12.2010 17:57, schrieb Antoine Pitrou: > > On Sat, 4 Dec 2010 02:45:42 +1000 > > Nick Coghlan wrote: > >> On Sat, Dec 4, 2010 at 2:28 AM, Antoine Pitrou wrote: > >> > On Fri, 03 Dec 2010 10:11:29 -0500 > >> > "R. David Murray" wrote: > >> >> > > >> >> > >>> 'abc'.transform('hex') > >> >> > TypeError: 'str' does not support the buffer interface > >> >> > >>> b'abc'.transform('rot13') > >> >> > TypeError: expected an object with the buffer interface > >> >> > >> >> I find these 'buffer interface' error messages to be the most confusing > >> >> error message I get out of Python3 no matter what context they show up > >> >> in. I have no idea what they are telling me. That issue is more > >> >> general than transform/untransform, but perhaps it could be fixed > >> >> for transform/untransform in particular. > >> > > >> > I agree. "buffer interface" is a technicality that the Python user > >> > doesn't do about (unless (s)he also writes C extensions). How about > >> > "expected a bytes-compatible object"? > >> > >> Why not "binary data interface"? That's what they're actually looking for. > > > > I don't think it's more understandable, since it's not a well-known > > Python concept. > > (and in this specific case, the transform() method is on str and bytes, > > not on arbitrary bytes-like objects) > > "object that can be handled as bytes"? > "object that provides bytes"? > > >> It seems odd for 'rot13' to be throwing that error though. > > > > Agreed. > > rot13 is a str<->str codec. Then why does it claim to expect an object with the buffer interface? bytes has the buffer interface, while str doesn't ;) I'll also mention that getting a TypeError when you call a method with the correct type of argument is a bit surprising. cheers Antoine. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] "buffer interface" messages
Am 03.12.2010 18:29, schrieb Antoine Pitrou: > On Fri, 03 Dec 2010 18:09:39 +0100 > Georg Brandl wrote: >> Am 03.12.2010 17:57, schrieb Antoine Pitrou: >> > On Sat, 4 Dec 2010 02:45:42 +1000 >> > Nick Coghlan wrote: >> >> On Sat, Dec 4, 2010 at 2:28 AM, Antoine Pitrou >> >> wrote: >> >> > On Fri, 03 Dec 2010 10:11:29 -0500 >> >> > "R. David Murray" wrote: >> >> >> > >> >> >> > >>> 'abc'.transform('hex') >> >> >> > TypeError: 'str' does not support the buffer interface >> >> >> > >>> b'abc'.transform('rot13') >> >> >> > TypeError: expected an object with the buffer interface >> >> >> >> >> >> I find these 'buffer interface' error messages to be the most confusing >> >> >> error message I get out of Python3 no matter what context they show up >> >> >> in. I have no idea what they are telling me. That issue is more >> >> >> general than transform/untransform, but perhaps it could be fixed >> >> >> for transform/untransform in particular. >> >> > >> >> > I agree. "buffer interface" is a technicality that the Python user >> >> > doesn't do about (unless (s)he also writes C extensions). How about >> >> > "expected a bytes-compatible object"? >> >> >> >> Why not "binary data interface"? That's what they're actually looking for. >> > >> > I don't think it's more understandable, since it's not a well-known >> > Python concept. >> > (and in this specific case, the transform() method is on str and bytes, >> > not on arbitrary bytes-like objects) >> >> "object that can be handled as bytes"? >> "object that provides bytes"? >> >> >> It seems odd for 'rot13' to be throwing that error though. >> > >> > Agreed. >> >> rot13 is a str<->str codec. > > Then why does it claim to expect an object with the buffer interface? > bytes has the buffer interface, while str doesn't ;) I'll leave it to you to figure it out. (Hint: look at the traceback.) > I'll also mention that getting a TypeError when you call a method with > the correct type of argument is a bit surprising. Why? The codec has the wrong type :) But seriously, MAL already proposed a bit more information on codecs, so that they can let it be known which types they convert between. Georg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com