summaryrefslogtreecommitdiff
path: root/src/semantic_version/compat.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-03-21 23:38:40 +0100
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-03-21 23:38:49 +0100
commit6aae60fb530f7608bc379a57a477e904a816544d (patch)
tree44a68fb691b7d9aeb0a560b54438f6f7180ce02d /src/semantic_version/compat.py
parenta77278819e5f9637e8ff1954ec33ecbf753ac89a (diff)
downloadsemantic-version-6aae60fb530f7608bc379a57a477e904a816544d.tar.gz
Add Python3 support.
Diffstat (limited to 'src/semantic_version/compat.py')
-rw-r--r--src/semantic_version/compat.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/semantic_version/compat.py b/src/semantic_version/compat.py
new file mode 100644
index 0000000..51102fc
--- /dev/null
+++ b/src/semantic_version/compat.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2012-2013 Raphaël Barrois
+# This code is distributed under the two-clause BSD License.
+
+import sys
+
+is_python2 = (sys.version_info[0] == 2)
+
+if is_python2: # pragma: no cover
+ base_cmp = cmp
+else: # pragma: no cover
+ def base_cmp(x, y):
+ if x < y:
+ return -1
+ elif x > y:
+ return 1
+ else:
+ return 0