Commit 6dbf9c10 authored by Martin v. Löwis's avatar Martin v. Löwis

Initialize msg to avoid unbound locals.

parent 7364c47f
...@@ -115,6 +115,7 @@ class FTP: ...@@ -115,6 +115,7 @@ class FTP:
if host: self.host = host if host: self.host = host
if port: self.port = port if port: self.port = port
self.passiveserver = 0 self.passiveserver = 0
msg = "getaddrinfo returns an empty list"
for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM): for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res af, socktype, proto, canonname, sa = res
try: try:
...@@ -270,6 +271,7 @@ class FTP: ...@@ -270,6 +271,7 @@ class FTP:
def makeport(self): def makeport(self):
'''Create a new socket and send a PORT command for it.''' '''Create a new socket and send a PORT command for it.'''
msg = "getaddrinfo returns an empty list"
for res in socket.getaddrinfo(None, 0, self.af, socket.SOCK_STREAM, 0, socket.AI_PASSIVE): for res in socket.getaddrinfo(None, 0, self.af, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
af, socktype, proto, canonname, sa = res af, socktype, proto, canonname, sa = res
try: try:
......
...@@ -357,6 +357,7 @@ class HTTPConnection: ...@@ -357,6 +357,7 @@ class HTTPConnection:
def connect(self): def connect(self):
"""Connect to the host and port specified in __init__.""" """Connect to the host and port specified in __init__."""
msg = "getaddrinfo returns an empty list"
for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM): for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res af, socktype, proto, canonname, sa = res
try: try:
......
...@@ -75,6 +75,7 @@ class POP3: ...@@ -75,6 +75,7 @@ class POP3:
def __init__(self, host, port = POP3_PORT): def __init__(self, host, port = POP3_PORT):
self.host = host self.host = host
self.port = port self.port = port
msg = "getaddrinfo returns an empty list"
for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM): for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res af, socktype, proto, canonname, sa = res
try: try:
......
...@@ -217,6 +217,7 @@ class SMTP: ...@@ -217,6 +217,7 @@ class SMTP:
raise socket.error, "nonnumeric port" raise socket.error, "nonnumeric port"
if not port: port = SMTP_PORT if not port: port = SMTP_PORT
if self.debuglevel > 0: print 'connect:', (host, port) if self.debuglevel > 0: print 'connect:', (host, port)
msg = "getaddrinfo returns an empty list"
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res af, socktype, proto, canonname, sa = res
try: try:
......
...@@ -136,6 +136,7 @@ class Telnet: ...@@ -136,6 +136,7 @@ class Telnet:
port = TELNET_PORT port = TELNET_PORT
self.host = host self.host = host
self.port = port self.port = port
msg = "getaddrinfo returns an empty list"
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res af, socktype, proto, canonname, sa = res
try: try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment