Re: [Python-Dev] [PEP466] SSLSockets, and sockets, _socketobjects oh my!

2014-07-23 Thread Nick Coghlan
On 24 Jul 2014 05:37, "Alex Gaynor" wrote: > > Possible solutions are: > > * Pass the SSLObject *in addition* to the _socket.socket object to the C code. > This generates some additional divergence from the Python3 code, but is > probably basically straightforward. > * Try to refactor the sock

Re: [Python-Dev] [PEP466] SSLSockets, and sockets, _socketobjects oh my!

2014-07-23 Thread Alex Gaynor
Antoine Pitrou python.org> writes: > > You mean for use with SSL_set_app_data? Yes, if you look in ``_servername_callback``, you can see where it uses ``SSL_get_app_data`` and then reads ``ssl->Socket``, which is supposed to be the same object that's returned by ``context.wrap_socket()``. A

Re: [Python-Dev] [PEP466] SSLSockets, and sockets, _socketobjects oh my!

2014-07-23 Thread Antoine Pitrou
Le 23/07/2014 15:36, Alex Gaynor a écrit : That said, I've hit another issue, with SNI callbacks. The first argument to an SNI callback is the socket. The callback is set up by some C code, which right now has access to only the _socket.socket object, not the ssl.SSLSocket object, which is what

Re: [Python-Dev] [PEP466] SSLSockets, and sockets, _socketobjects oh my!

2014-07-23 Thread Alex Gaynor
Antoine Pitrou python.org> writes: > No, IIRC there shouldn't be a cycle. It's just complicated in a > different way than 3.x > > Regards > > Antoine. > Indeed, you're right, this is just differently convoluted so no leak (not that I would call "collected by a normal GC" a leak :-)). That s

Re: [Python-Dev] [PEP466] SSLSockets, and sockets, _socketobjects oh my!

2014-07-22 Thread Antoine Pitrou
Le 22/07/2014 17:44, Nick Coghlan a écrit : > > As for 2.x, I don't see why you couldn't just continue using a strong reference. As Antoine says, if the cycle already exists in Python 2 (and it sounds like it does), we can just skip backporting the weak reference change. No, IIRC there shou

Re: [Python-Dev] [PEP466] SSLSockets, and sockets, _socketobjects oh my!

2014-07-22 Thread Nick Coghlan
On 23 Jul 2014 07:28, "Antoine Pitrou" wrote: > > Le 22/07/2014 17:03, Alex Gaynor a écrit : > >> >> The question is: >> >> a) Should we backport weak referencing _socket.sockets (changing the structure >> of the module seems overly invasive, albeit completely backwards >> compatible)? >>

Re: [Python-Dev] [PEP466] SSLSockets, and sockets, _socketobjects oh my!

2014-07-22 Thread Antoine Pitrou
Le 22/07/2014 17:03, Alex Gaynor a écrit : The question is: a) Should we backport weak referencing _socket.sockets (changing the structure of the module seems overly invasive, albeit completely backwards compatible)? b) Does anyone know why weak references are used in the first place? T

[Python-Dev] [PEP466] SSLSockets, and sockets, _socketobjects oh my!

2014-07-22 Thread Alex Gaynor
Hi all, I've been happily working on the SSL module backports for Python2 (pursuant to PEP466), and I've hit something of a snag: In python3, the SSLSocket keeps a weak reference to the underlying socket, rather than a strong reference, as Python2 uses. Unfortunately, due to the way sockets work