Skip to content

Commit

Permalink
socket.error → OSError
Browse files Browse the repository at this point in the history
In Python ≥ 3.3, socket.error is an alias of OSError.

https://docs.python.org/3/library/socket.html#socket.error

This is a suggestion from pyupgrade:
https://github.com/asottile/pyupgrade#oserror-aliases
  • Loading branch information
DimitriPapadopoulos authored and abravalheri committed Nov 20, 2023
1 parent 5069f6c commit 7a85110
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions setuptools/command/upload_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from distutils import log
from distutils.errors import DistutilsOptionError
import os
import socket
import zipfile
import tempfile
import shutil
Expand Down Expand Up @@ -201,7 +200,7 @@ def upload_file(self, filename):
conn.putheader('Authorization', auth)
conn.endheaders()
conn.send(body)
except socket.error as e:
except OSError as e:
self.announce(str(e), log.ERROR)
return

Expand Down
2 changes: 1 addition & 1 deletion setuptools/package_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ def open_url(self, url, warning=None): # noqa: C901 # is too complex (12)
'%s returned a bad status line. The server might be '
'down, %s' % (url, v.line)
) from v
except (http.client.HTTPException, socket.error) as v:
except (http.client.HTTPException, OSError) as v:
if warning:
self.warn(warning, v)
else:
Expand Down

0 comments on commit 7a85110

Please sign in to comment.