diff --git a/Lib/ftplib.py b/Lib/ftplib.py index 94237caf214..a0f0f90fd0e 100644 --- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -291,7 +291,8 @@ def makeport(self): try: sock = socket.socket(af, socktype, proto) sock.bind(sa) - except socket.error as err: + except socket.error as _: + err = _ if sock: sock.close() sock = None