From 4ddd1821b6c8556c79c202d8a9df19c576202ec1 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 20 Oct 2015 19:01:23 +0200 Subject: [PATCH] ipapython.nsslib, ipalib.rpc: Remove code for Python 2.6 and below IPA hasn't supported these pythons for a while now. Reviewed-By: Tomas Babej --- ipalib/rpc.py | 33 ++++++++++++--------------------- ipapython/nsslib.py | 8 +------- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/ipalib/rpc.py b/ipalib/rpc.py index 6a7f6982b..02281d404 100644 --- a/ipalib/rpc.py +++ b/ipalib/rpc.py @@ -480,12 +480,9 @@ class SSLTransport(LanguageAwareTransport): def make_connection(self, host): host, self._extra_headers, x509 = self.get_host_info(host) - # Python 2.7 changed the internal class used in xmlrpclib from - # HTTP to HTTPConnection. We need to use the proper subclass - if sys.version_info >= (2, 7): - if self._connection and host == self._connection[0]: - return self._connection[1] + if self._connection and host == self._connection[0]: + return self._connection[1] dbdir = getattr(context, 'nss_dir', paths.IPA_NSSDB_DIR) connection_dbdir = self.get_connection_dbdir() @@ -500,20 +497,15 @@ class SSLTransport(LanguageAwareTransport): # need to re-initialize. no_init = dbdir == ipapython.nsslib.current_dbdir - if sys.version_info < (2, 7): - conn = NSSHTTPS(host, 443, dbdir=dbdir, no_init=no_init) - else: - conn = NSSConnection(host, 443, dbdir=dbdir, no_init=no_init, - tls_version_min=api.env.tls_version_min, - tls_version_max=api.env.tls_version_max) + conn = NSSConnection(host, 443, dbdir=dbdir, no_init=no_init, + tls_version_min=api.env.tls_version_min, + tls_version_max=api.env.tls_version_max) self.dbdir=dbdir conn.connect() - if sys.version_info < (2, 7): - return conn - else: - self._connection = host, conn - return self._connection[1] + + self._connection = host, conn + return self._connection[1] class KerbTransport(SSLTransport): @@ -925,11 +917,10 @@ class RPCClient(Connectible): return serverproxy def destroy_connection(self): - if sys.version_info >= (2, 7): - conn = getattr(context, self.id, None) - if conn is not None: - conn = conn.conn._ServerProxy__transport - conn.close() + conn = getattr(context, self.id, None) + if conn is not None: + conn = conn.conn._ServerProxy__transport + conn.close() def _call_command(self, command, params): """Call the command with given params""" diff --git a/ipapython/nsslib.py b/ipapython/nsslib.py index 0d02e768b..52cf63f03 100644 --- a/ipapython/nsslib.py +++ b/ipapython/nsslib.py @@ -291,13 +291,7 @@ class NSSConnection(httplib.HTTPConnection, NSSAddressFamilyFallback): """ try: # FIXME: httplib uses old-style classes so super doesn't work - # Python 2.7 changed the API for endheaders. This is an attempt - # to work across versions - (major, minor, micro, releaselevel, serial) = sys.version_info - if major == 2 and minor < 7: - httplib.HTTPConnection.endheaders(self) - else: - httplib.HTTPConnection.endheaders(self, message) + httplib.HTTPConnection.endheaders(self, message) except NSPRError as e: self.close() raise e