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” option enabled,
> and most of the buildbots appear to be affected. (In 3.6 the tests
> have temporarily been disabled as a workaround.) I have a simple patch
> that subsitutes the old root certificate for the new which I would
> like to commit, but I’m not sure which branches to apply it to, or
> even which branches are open to normal maintainence and bug fixes.

As mentioned on the issue tracker I'm not convinced that your
patch is a good solution going forward. Rather than basing
the test on svn.python.org, which can change again in the
future, we should use the domain we have specifically
reserved for stdlib tests, namely pythontest.net and get this
set up in a way so that we can run SSL tests again.

I can help with getting SSL certificates for pythontest.net,
since I'm managing the PSF SSL certificates (well, trying to
keep those managed anyway ;-) - I was not involved in the
choice of new CA for svn.python.org):

https://wiki.python.org/psf/PSF%20SSL%20Certificates

Regarding which branches to apply the final fix, others have
already chimed in. Essentially, any branch which we'll need
to run tests on in the foreseeable future will need to be fixed,
since the change in svn.python.org's SSL setup (the expired
certificate which caused the tests to fail was replaced with
a new one from a different CA, again causing tests to fail)
affects all released test suites.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Jan 07 2016)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> Python Database Interfaces ...   http://products.egenix.com/
>>> Plone/Zope Database Interfaces ...   http://zope.egenix.com/


::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
  http://www.malemburg.com/

___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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 now be in security-fixes-only mode.

Would it be possible to have a (clear and up to date) table like
http://docs.openstack.org/releases/ in the Developer Guide? List of
Python versions with their status (end of life, security supported,
current stable release, under development).

Victor
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[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 bytearray. I have a ByteArray_Xor function that I think should do this
here
https://github.com/cowlicks/cpython/commit/d6dddb11cdb33032b39dcb9dfdaa7b10d4377b5f

But I'm not sure how to hook this in to the rest of cypython. I tried
adding it where bytearray_as_sequence is declared in this bytearrayobject.c
file. But that gave me compiler warnings and broke things.

So now that I have this ByteArray_Xor function, how do I make it be
bytearray.__xor___?

Thanks!

Blake
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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 operations.
>
> I've never hacked on cpython before. I'm starting by just trying to add
> xor to bytearray. I have a ByteArray_Xor function that I think should do
> this here
> https://github.com/cowlicks/cpython/commit/d6dddb11cdb33032b39dcb9dfdaa7b10d4377b5f
>
> But I'm not sure how to hook this in to the rest of cypython. I tried
> adding it where bytearray_as_sequence is declared in this
> bytearrayobject.c file. But that gave me compiler warnings and broke things.
>
> So now that I have this ByteArray_Xor function, how do I make it be
> bytearray.__xor___?
>

You need to set the PyNumberMethods struct with the appropriate function
and then set that on the PyTypeObject. Look at
https://hg.python.org/cpython/file/tip/Include/object.h#l237 and
https://hg.python.org/cpython/file/tip/Objects/longobject.c#l5238 for an
idea of what it takes.
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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. Also, variable length arrays are added in C99, so you
will need to manually allocate the `raw_*` arrays in the heap. This seems
like a cool feature!

On Thu, Jan 7, 2016 at 5:26 PM, 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 operations.
>
> I've never hacked on cpython before. I'm starting by just trying to add
> xor to bytearray. I have a ByteArray_Xor function that I think should do
> this here
> https://github.com/cowlicks/cpython/commit/d6dddb11cdb33032b39dcb9dfdaa7b10d4377b5f
>
> But I'm not sure how to hook this in to the rest of cypython. I tried
> adding it where bytearray_as_sequence is declared in this
> bytearrayobject.c file. But that gave me compiler warnings and broke things.
>
> So now that I have this ByteArray_Xor function, how do I make it be
> bytearray.__xor___?
>
> Thanks!
>
> Blake
>
> ___
> Python-Dev mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/joe%40quantopian.com
>
>
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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.

There is a bug open about adding this kind of functionality:
.
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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' TypeError.
>> 
>> I think both bytes and bytearray should support all the bitwise operations.
> 
> There is a bug open about adding this kind of functionality:
> .

And it's in the needs patch stage, which makes it perfect for the OP: in 
addition to learning how to hack on builtin types, he can also learn the other 
parts of the dev process. (Even if the bug is eventually rejected, as seems 
likely given that it sat around for three years with no compelling use case  
and then Guido added a "very skeptical" comment.)
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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 pointed out this feature was suggested on the mailing list a
while back (2006)
https://mail.python.org/pipermail/python-dev/2006-March/061980.html

On Fri, Jan 8, 2016 at 1:12 AM, Andrew Barnert  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'
> >> b'\x03'
> >>
> >>
> >> Instead of the good ol' TypeError.
> >>
> >> I think both bytes and bytearray should support all the bitwise
> operations.
> >
> > There is a bug open about adding this kind of functionality:
> > .
>
> And it's in the needs patch stage, which makes it perfect for the OP: in
> addition to learning how to hack on builtin types, he can also learn the
> other parts of the dev process. (Even if the bug is eventually rejected, as
> seems likely given that it sat around for three years with no compelling
> use case  and then Guido added a "very skeptical" comment.)
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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'

b'\x03'
Instead of the good ol' TypeError.

I think both bytes and bytearray should support all the bitwise operations.


There is a bug open about adding this kind of functionality:
.


And it's in the needs patch stage, which makes it perfect for the OP: in 
addition to learning how to hack on builtin types, he can also learn the other 
parts of the dev process. (Even if the bug is eventually rejected, as seems 
likely given that it sat around for three years with no compelling use case  
and then Guido added a "very skeptical" comment.)


The use case which springs immediately to my mind is cryptography. To encrypt a 
stream symmetrically you can go:


 cleartext-bytes ^ cryptographicly-random-bytes-from-cipher

so with this one could write:

 def crypted(byteses, crypto_source):
   ''' Accept an iterable source of bytes objects and a preprimed source of 
   crypto bytes, yield encrypted versions of the bytes objects.

   '''
   for bs in byteses:
 cbs = crypto_source.next_bytes(len(bs))
 yield bs ^ cbs

Cheers,
Cameron Simpson 
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com