Re: [Python-Dev] bitwise operations for bytes and bytearray

2016-01-07 Thread Joe Jevnik
You want to put the `xor` method in the `nb_xor` field of the `PyNumberMethods` structure that lives in the `tp_as_number` field of the bytes type object. Two things I noticed in a quick pass: you might want to add some type checking around the case where `a` or `b` is not a `PyByteArray` object.

Re: [Python-Dev] bitwise operations for bytes and bytearray

2016-01-07 Thread Andrew Barnert via Python-Dev
On Jan 7, 2016, at 15:57, Martin Panter wrote: > >> On 7 January 2016 at 22:26, Blake Griffith >> wrote: >> I'm interested in adding the functionality to do something like: >> > b'a' ^ b'b' >> b'\x03' >> >> >> Instead of the good ol'

Re: [Python-Dev] bitwise operations for bytes and bytearray

2016-01-07 Thread Blake Griffith
Thanks for the quick responses y'all. I have something compiling on my branch, which is enough for me tonight. I asked a question about this on stackoverflow a while ago, it wasn't very popular https://stackoverflow.com/questions/32658420/why-cant-you-xor-bytes-objects-in-python Someone there

Re: [Python-Dev] bitwise operations for bytes and bytearray

2016-01-07 Thread Martin Panter
On 7 January 2016 at 22:26, Blake Griffith wrote: > I'm interested in adding the functionality to do something like: > b'a' ^ b'b' > b'\x03' > > > Instead of the good ol' TypeError. > > I think both bytes and bytearray should support all the bitwise operations.

Re: [Python-Dev] bitwise operations for bytes and bytearray

2016-01-07 Thread Cameron Simpson
On 07Jan2016 16:12, Python-Dev wrote: On Jan 7, 2016, at 15:57, Martin Panter wrote: On 7 January 2016 at 22:26, Blake Griffith wrote: I'm interested in adding the functionality to do something like: b'a' ^ b'b'

Re: [Python-Dev] Branches in which to fix the SSL tests

2016-01-07 Thread M.-A. Lemburg
On 07.01.2016 04:06, Martin Panter wrote: > Currently some SSL tests in the test suite are broken by a recent > certificate change at https://svn.python.org/; see > for the bug report. The tests are > broken when the test suite is run with the “-unetwork”

Re: [Python-Dev] Branches in which to fix the SSL tests

2016-01-07 Thread Victor Stinner
Hi, 2016-01-07 17:32 GMT+01:00 Larry Hastings : > On 01/06/2016 10:06 PM, Martin Panter wrote: > > According to Larry > , > 3.4.4 was the last bug fix release for 3.4, so I assumed the 3.4 > branch should

[Python-Dev] bitwise operations for bytes and bytearray

2016-01-07 Thread Blake Griffith
Hi! I'm interested in adding the functionality to do something like: >>> b'a' ^ b'b' b'\x03' Instead of the good ol' TypeError. I think both bytes and bytearray should support all the bitwise operations. I've never hacked on cpython before. I'm starting by just trying to add xor to

Re: [Python-Dev] bitwise operations for bytes and bytearray

2016-01-07 Thread Brett Cannon
On Thu, 7 Jan 2016 at 14:29 Blake Griffith wrote: > Hi! > > I'm interested in adding the functionality to do something like: > > >>> b'a' ^ b'b' > b'\x03' > > > Instead of the good ol' TypeError. > > I think both bytes and bytearray should support all the bitwise