From a9464c14fc6dfc23613a1ec89446393fe6476f88 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 31 Oct 2012 17:31:12 +0100 Subject: * Python 2.7 is not required. Python 2.6 is no longer officially supported. The code base is now also `python2.7 -3` clean, although there are still some warnings in 3rd party dependencies. LP: #1073506 --- src/mailman/testing/helpers.py | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'src/mailman/testing/helpers.py') diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py index 054dd4ff7..99f4b8961 100644 --- a/src/mailman/testing/helpers.py +++ b/src/mailman/testing/helpers.py @@ -249,8 +249,8 @@ def get_lmtp_client(quiet=False): if not quiet: print(response) return lmtp - except socket.error as error: - if error[0] == errno.ECONNREFUSED: + except IOError as error: + if error.errno == errno.ECONNREFUSED: time.sleep(0.1) else: raise @@ -284,8 +284,8 @@ def wait_for_webservice(): try: socket.socket().connect((config.webservice.hostname, int(config.webservice.port))) - except socket.error as error: - if error[0] == errno.ECONNREFUSED: + except IOError as error: + if error.errno == errno.ECONNREFUSED: time.sleep(0.1) else: raise @@ -515,19 +515,3 @@ class LogFileMark: with open(self._filename) as fp: fp.seek(self._filepos) return fp.readline() - - - -# In Python 2.6, body_line_iterator() uses a cStringIO.StringIO() which cannot -# handle unicode. In Python 2.7 this works fine. I hate version checks but -# this is the easiest way to handle it. OTOH, we could just use the manual -# way for all Python versions instead. -import sys -if sys.hexversion >= 0x2070000: - from email.iterators import body_line_iterator -else: - def body_line_iterator(msg, decode=False): - payload = msg.get_payload(decode=decode) - bytes_payload = payload.encode('utf-8') - for line in bytes_payload.splitlines(): - yield line -- cgit v1.2.3-70-g09d2