[issue35422] misleading error message from ssl.get_server_certificate() when bad port

2018-12-05 Thread Cédric Van Rompay

New submission from Cédric Van Rompay :

When calling ssl.get_server_certificate() with a bad port number (I used 80 
when I should have been using 443), the error raised is a bit misleading:

>>> import ssl
>>> ssl.get_server_certificate(('gitlab.com',80))
[...]
SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:847)

"SSL: wrong version number" seems to indicate that there is a mismatch between 
SSL versions supported by the client and the ones supported by the server. When 
here I guess the problem would better be described as "there is no SSL 
available at this address+port".

--
assignee: christian.heimes
components: SSL
messages: 331171
nosy: cedricvanrompay, christian.heimes
priority: normal
severity: normal
status: open
title: misleading error message from ssl.get_server_certificate() when bad port
type: behavior
versions: Python 3.6

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



[issue35216] misleading error message from shutil.copy()

2018-11-12 Thread Cédric Van Rompay

New submission from Cédric Van Rompay :

When calling `shutil.copy('file.txt', 'not_here/')`,
if directory `not_here/` does not exist,
the raised error is:

IsADirectoryError: [Errno 21] Is a directory: 'not_here/'

If the intent of the user was to copy a file in a directory
but the user forgot to create the destination directory,
this can be very misleading,
as the error tends to indicate that the directory exists.

It happened to me and I was thinking
"yes it's a directory, then what?
that's exactly what I want,copy to this directory!"
when the problem was that I forgot to create the destination directory.

I would suggest to catch the `IsADirectoryError`
in shutil.copyfile() (at `open(dst, 'wb')`)
and raise instead an error saying something like
"destination is a directory AND this directory does not exists".

--
components: Library (Lib)
messages: 329728
nosy: cedricvanrompay
priority: normal
severity: normal
status: open
title: misleading error message from shutil.copy()
type: behavior
versions: Python 3.6

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