[issue33023] Unable to copy ssl.SSLContext

2021-04-17 Thread Christian Heimes


Change by Christian Heimes :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-12-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 324e1790094708538acf2e7795f9c44e3732aaf7 by Serhiy Storchaka in 
branch '2.7':
[2.7] bpo-33023: Fix NotImplemented to NotImplementedError. (GH-10934). 
(GH-11001) (GH-11008)
https://github.com/python/cpython/commit/324e1790094708538acf2e7795f9c44e3732aaf7


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-12-06 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +10242

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-12-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 7a2cf1e7d3bf300e98c702589d405734f4a8fcf8 by Serhiy Storchaka in 
branch '3.6':
bpo-33023: Fix NotImplemented to NotImplementedError. (GH-10934). (GH-11001)
https://github.com/python/cpython/commit/7a2cf1e7d3bf300e98c702589d405734f4a8fcf8


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-12-06 Thread miss-islington


miss-islington  added the comment:


New changeset 6485aa6eb1024672f08afdd577e2b5792eb6b03c by Miss Islington (bot) 
in branch '3.7':
bpo-33023: Fix NotImplemented to NotImplementedError. (GH-10934)
https://github.com/python/cpython/commit/6485aa6eb1024672f08afdd577e2b5792eb6b03c


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-12-06 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +10240

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-12-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +10239

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-12-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 42b1d6127bd8595522a78a75166ebb9fba74a6a2 by Serhiy Storchaka in 
branch 'master':
bpo-33023: Fix NotImplemented to NotImplementedError. (GH-10934)
https://github.com/python/cpython/commit/42b1d6127bd8595522a78a75166ebb9fba74a6a2


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-12-05 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 10934 fixes just a typo in the name of NotImplementedError. It fixes also a 
similar typo in IDLE. It adds new tests and fixes existing tests for 
NotImplementedError in SSLSocket.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-12-05 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +10189

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-10-31 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

After discussing on Python-Dev all error messages were changed to "cannot 
pickle 'XXX' object".

https://mail.python.org/pipermail/python-dev/2018-October/155599.html

I suggest to not add __getstate__() methods with different error messages. But 
the dup() method should be fixed.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-06-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

If changes to __getstate__() be merged in 2.7, I suggest to unify them with 
issue33138.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-06-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The change to the dup() method looks as a bug fix to me. It needs to be 
backported to all maintained versions. New tests can be backported to all 
versions except perhaps 2.7 (not tested). Changes to __getstate__() will be not 
needed if merge issue33138 PR 6239 (they just change the error message). But it 
may be needed to apply them to 2.7 only.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-06-06 Thread Ned Deily


Ned Deily  added the comment:

We have a languishing PR here.  What should be done with it?  If I understand 
correctly, Serhiy is proposing a more general cleanup in Issue33138 PR 6239.  
If that is merged, can PR 6099 here be simplified?  What branches should it 
apply to? (retargeting for 3.8 pending comments)

--
nosy: +ned.deily
versions: +Python 3.8 -Python 2.7, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-25 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

See issue33138.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-25 Thread Christian Heimes

Christian Heimes  added the comment:

That's the only reason for PR 6099. The change makes it more obvious that SSL 
objects can't be serialized or copied.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-24 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Christian, I thought the reason of adding __getstate__ methods which raise an 
exception is that the existing error message doesn't satisfy your. What is the 
other reason?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-24 Thread Vitaly Kruglikov

Vitaly Kruglikov  added the comment:

Thank you, I'll consider myself having been warned :)

On Sat, Mar 24, 2018, 7:28 AM Christian Heimes 
wrote:

>
> Christian Heimes  added the comment:
>
> Serhiy,
> I don't understand what you are trying to tell me. "cannot serialize '%s'
> object" is used all over the interpreter, e.g. io, pickle, etree, and more.
> I feel it's the standard message.
>
> Vitaly,
> A lot of objects can't be copied. It's the general case for all kinds of
> objects that hold operating system resources (files, sockets) or wrap
> external C libraries (bz2, lzma, sqlite, ssl). We generally don't document
> that an object cannot be pickled, serialized, or copied. If documentation
> doesn't state that an object is copy-able or doesn't provide a dedicated
> copy method, than it can't be copied.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-24 Thread Christian Heimes

Christian Heimes  added the comment:

Serhiy,
I don't understand what you are trying to tell me. "cannot serialize '%s' 
object" is used all over the interpreter, e.g. io, pickle, etree, and more. I 
feel it's the standard message.

Vitaly,
A lot of objects can't be copied. It's the general case for all kinds of 
objects that hold operating system resources (files, sockets) or wrap external 
C libraries (bz2, lzma, sqlite, ssl). We generally don't document that an 
object cannot be pickled, serialized, or copied. If documentation doesn't state 
that an object is copy-able or doesn't provide a dedicated copy method, than it 
can't be copied.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-23 Thread Vitaly Kruglikov

Vitaly Kruglikov  added the comment:

It would be very helpful to make a statement in SSLContext's documentation to 
the effect that it's not copyable. This is frankly the first time I run into a 
non-copyable object.I spend quite a bit of time researching this after 
implementing a copying strategy that failed. It would have saved me (and 
others...) so much time is there was a warning in SSLContext documentation 
about not being able to serialize/copy/deepcopy by design!

Also, making that exception message more generic (ha, I wasn't pickling 
anything?!) as Serhiy Storchaka suggested would be a welcome addition, but not 
replacement for documentation.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-23 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

PR 6099 changes error message "can't pickle SSLContext objects" to "cannot 
serialize SSLContext object", right? Wouldn't be better to change the standard 
error message instead?

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-13 Thread Christian Heimes

Christian Heimes  added the comment:

Antoine is correct. Session resumption is fully transparent for the application 
layer. The context object is designed to be reused by multiple connections to 
same or different servers.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-13 Thread Christian Heimes

Change by Christian Heimes :


--
keywords: +patch
pull_requests: +5862
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-12 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

You won't have any session resumption tickets until a connection succeeds.  And 
even then, I don't think it would be a problem.  By design, SSL contexts are 
meant to be re-used accross multiple connections.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-12 Thread Vitaly Kruglikov

Vitaly Kruglikov  added the comment:

> What would those side-effects be?

Christian Heimes suggested that 
> A context contains elements that can't be cloned easily, e.g. session 
> resumption tickets.

My concern then would be potential side-effects from such session resumption 
tickets and anything else that one connection attempt might save/change within 
an SSL Context that might have an undesirable side-effect on the follow-on 
connection attempts.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-11 Thread Antoine Pitrou

Change by Antoine Pitrou :


--
type: crash -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-11 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> Each connection attempt will require a fresh unadulterated clone of the 
> ssl.SSLContext instance provided by user to avoid any side-effects from prior 
> connection attempts.

What would those side-effects be?

--
nosy: +pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-08 Thread Vitaly Kruglikov

Vitaly Kruglikov  added the comment:

Also, updating ssl.SSLContext documentation about intentional inability to copy 
generically and suggestion how to go about it if you need to obtain a clone or 
similar would be terrific and save developers time so they won't run into this 
gotcha when designing and implementing solutions. Many thanks!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-08 Thread Vitaly Kruglikov

Vitaly Kruglikov  added the comment:

Hi Christian, thank you for following up. Here is my use case, and perhaps you 
can suggest something else that will work:

I am refactoring the transport layer in the Pika AMQP client library. The user 
provides an ssl.SSLContext instance for connecting to an AMQP broker (e.g., 
RabbitMQ). Pika will resolve the hostname via getaddrinfo and make attempts to 
establish TCP and AMQP connection to the candidate IP addresses until one 
succeeds in establishing an AMQP connection over SSL. Each connection attempt 
will require a fresh unadulterated clone of the ssl.SSLContext instance 
provided by user to avoid any side-effects from prior connection attempts.

How can I obtain this pristine clone cleanly for each new connection attempt?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-08 Thread Christian Heimes

Christian Heimes  added the comment:

This is rather a feature than a bug. It is not possible to make a copy of a 
SSLContext object because OpenSSL doesn't support the operation. A context 
contains elements that can't be cloned easily, e.g. session resumption tickets.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-07 Thread Vitaly Kruglikov

Change by Vitaly Kruglikov :


--
assignee:  -> christian.heimes
components: +SSL
nosy: +christian.heimes

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-07 Thread Vitaly Kruglikov

New submission from Vitaly Kruglikov :

```
import copy
import ssl

copy.copy(ssl.create_default_context())
```
results in 

`TypeError: can't pickle SSLContext objects`

This prevents me from being able to `copy.deepcopy()` an object that references 
`ssl.SSLContext`.

The apparent root cause is apparently that `ssl.SSLContext` passes an extra arg 
to its `__new__` method, but doesn't implement the method `__getnewargs__` that 
would let `copy` extract the extra arg.

--
messages: 313422
nosy: vitaly.krug
priority: normal
severity: normal
status: open
title: Unable to copy ssl.SSLContext
versions: Python 2.7, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33023] Unable to copy ssl.SSLContext

2018-03-07 Thread Vitaly Kruglikov

Change by Vitaly Kruglikov :


--
type:  -> crash

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com