Yet another fix for python ssl distro compatibility

Apparently CentOS 7 just decided to backport the SSL patches from 2.7.9
to 2.7.5! Sigh.

I have no idea if this change will cause installation to stop working on
old Debian/Ubuntu. I love linux.

Fixes #1551800 [Automatic Linux install fails with SSL error](https://bugs.launchpad.net/calibre/+bug/1551800)
This commit is contained in:
Kovid Goyal 2016-03-01 22:16:53 +05:30
parent 615303a143
commit 3eaf62de5b
2 changed files with 3 additions and 5 deletions

View File

@ -20,7 +20,7 @@ if enc.lower() == 'ascii':
enc = 'utf-8' enc = 'utf-8'
calibre_version = signature = None calibre_version = signature = None
urllib = __import__('urllib.request' if py3 else 'urllib', fromlist=1) urllib = __import__('urllib.request' if py3 else 'urllib', fromlist=1)
has_ssl_verify = hasattr(ssl, 'PROTOCOL_TLSv1_2') and sys.version_info[:3] > (2, 7, 8) has_ssl_verify = hasattr(ssl, 'create_default_context')
if py3: if py3:
unicode = str unicode = str

View File

@ -6,14 +6,12 @@ from __future__ import (unicode_literals, division, absolute_import,
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>' __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
import ssl, socket, re, sys import ssl, socket, re
from contextlib import closing from contextlib import closing
from calibre import get_proxies from calibre import get_proxies
from calibre.constants import ispy3 from calibre.constants import ispy3
# On OS X PROTOCOL_TLSv1_2 is not available because the SSL library shipped has_ssl_verify = hasattr(ssl, 'create_default_context') and hasattr(ssl, '_create_unverified_context')
# with OS X is too old
has_ssl_verify = sys.version_info[:3] > (2, 7, 8)
class HTTPError(ValueError): class HTTPError(ValueError):