redefine cmp under py3k. Closes #120635

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changeset07f199a99d3b
branchdefault
phasepublic
hiddenno
parent revision#1de0c6ed5be4 use .fromlineno instead of .lineno (which is not reliable)
child revision#9ee22d817eda use load_module_from_file rather than relative import broken in python 3.3. Closes #110213
files modified by this revision
reporters/__init__.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1361545663 -3600
# Fri Feb 22 16:07:43 2013 +0100
# Node ID 07f199a99d3bb63f74cb7425e4a69a1740392cc9
# Parent 1de0c6ed5be45a0180bd9eb4612ff3f2728c220d
redefine cmp under py3k. Closes #120635

diff --git a/reporters/__init__.py b/reporters/__init__.py
@@ -1,7 +1,7 @@
1  # Copyright (c) 2003-2010 Sylvain Thenault (thenault@gmail.com).
2 -# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
3 +# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE).
4  # This program is free software; you can redistribute it and/or modify it under
5  # the terms of the GNU General Public License as published by the Free Software
6  # Foundation; either version 2 of the License, or (at your option) any later
7  # version.
8  #
@@ -16,10 +16,15 @@
9 
10  import sys, locale
11 
12  CMPS = ['=', '-', '+']
13 
14 +# py3k has no more cmp builtin
15 +if sys.version_info >= (3, 0):
16 +    def cmp(a, b):
17 +        return (a > b) - (a < b)
18 +
19  def diff_string(old, new):
20      """given a old and new int value, return a string representing the
21      difference
22      """
23      diff = abs(old - new)