Alex Gaynor
2014-07-22 21:03:36 UTC
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 in Python2, this doesn't work:
On Python2, _socketobject composes around _real_socket from the _socket module,
whereas on Python3, it subclasses _socket.socket. Since you now have a Python-
level class, you can weak reference it.
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? The commit
message just alludes to fixing a leak with no reference to an issue.
Anyone who's interested in the state of the branch can see it at:
github.com/alex/cpython on the backport-ssl branch. Note that many many tests
are still failing, and you'll need to apply the patch from
http://bugs.python.org/issue22023 to get it to work.
Thanks,
Alex
PS: Any help in getting http://bugs.python.org/issue22023 landed which be very
much appreciated.
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 in Python2, this doesn't work:
On Python2, _socketobject composes around _real_socket from the _socket module,
whereas on Python3, it subclasses _socket.socket. Since you now have a Python-
level class, you can weak reference it.
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? The commit
message just alludes to fixing a leak with no reference to an issue.
Anyone who's interested in the state of the branch can see it at:
github.com/alex/cpython on the backport-ssl branch. Note that many many tests
are still failing, and you'll need to apply the patch from
http://bugs.python.org/issue22023 to get it to work.
Thanks,
Alex
PS: Any help in getting http://bugs.python.org/issue22023 landed which be very
much appreciated.