From 1e291afdfa2d005b958b7315c7e02ac0d3cc7fa2 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Tue, 28 Jun 2016 21:55:10 +0200 Subject: [PATCH 1/2] Fix python requests version check --- linkcheck/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/linkcheck/__init__.py b/linkcheck/__init__.py index 56248556..77f25835 100644 --- a/linkcheck/__init__.py +++ b/linkcheck/__init__.py @@ -24,10 +24,17 @@ import sys # Needs Python >= 2.7.2 which fixed http://bugs.python.org/issue11467 if not (hasattr(sys, 'version_info') or sys.version_info < (2, 7, 2, 'final', 0)): - raise SystemExit("This program requires Python 2.7.2 or later.") + import platform + version = platform.python_version() + raise SystemExit("This program requires Python 2.7.2 or later instead of %s." % version) +# require a reasonably recent requests module: 2.4.0 from 2014-08-29 import requests -if requests.__version__ <= '2.2.0': - raise SystemExit("This program requires Python requests 2.2.0 or later.") +# PEP 396 has only version strings, bummer! PEP 386 is also not helpful. +requests_version = requests.__version__.split('.') +# Depends on the version scheme of Python requests +if int(requests_version[0]) < 2 or \ + (int(requests_version[0]) == 2 and int(requests_version[1]) < 4): + raise SystemExit("This program requires Python requests 2.4.0 or later instead of %s." % requests.__version__) import os # add the custom linkcheck_dns directory to sys.path From bf45fb1884151aa612ceddb8c6b2caf9ec8b8af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Thu, 19 May 2016 14:49:55 -0400 Subject: [PATCH 2/2] fix HTTPS URL checks in Debian Jessie, linkchecker fails because of an API problem. it completely breaks HTTPs checks. this patch fixes the problem from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=772947 --- linkcheck/httputil.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linkcheck/httputil.py b/linkcheck/httputil.py index d59a0623..30d1c0c8 100644 --- a/linkcheck/httputil.py +++ b/linkcheck/httputil.py @@ -32,14 +32,14 @@ def x509_to_dict(x509): """Parse a x509 pyopenssl object to a dictionary with keys subject, subjectAltName and optional notAfter. """ - from requests.packages.urllib3.contrib.pyopenssl import get_subj_alt_name + import requests.packages.urllib3.contrib.pyopenssl as SSL res = { 'subject': ( (('commonName', x509.get_subject().CN),), ), 'subjectAltName': [ ('DNS', value) - for value in get_subj_alt_name(x509) + for value in SSL.get_subj_alt_name(x509) ] } notAfter = x509.get_notAfter()