summaryrefslogtreecommitdiff
blob: 905b7f718414779b6730ff33ba9111af529214da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From c2ce810c3fb00b895a841a7be6b2e78c64e7b042 Mon Sep 17 00:00:00 2001
From: Bastian Kleineidam <bastian.kleineidam@web.de>
Date: Tue, 28 Jun 2016 21:55:10 +0200
Subject: [PATCH] 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 22a0cf5..1cec214 100644
--- a/linkcheck/__init__.py
+++ b/linkcheck/__init__.py
@@ -24,10 +24,17 @@
 # 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