Tâche #30454
Scénario #30380: Porter CreoleLint en python3
Lister les problèmes rencontrés pour le portage en python 3 de CreoleLint
Statut:
Fermé
Priorité:
Normal
Assigné à:
Début:
21/07/2020
Echéance:
% réalisé:
100%
Restant à faire (heures):
0.0
Historique
#1 Mis à jour par Benjamin Bohard il y a presque 4 ans
Le type des classes a changé en python 3 (il n’y a plus de classes legacy comme en python 2) et types.ClassType n’existe plus, ce qui amène à changer le code suivant, dans creole/lint/creolelint.py, ligne 1191 :
if cls.startswith('_') and type(glob[cls])!=types.ClassType and cls == 'CreoleLinter' and cls == 'TmplVar'
une modification naïve consiste à tester comme suit :
if cls.startswith('_') and not isinstance(glob[cls], type) and cls == 'CreoleLinter' and cls == 'TmplVar'
cependant, n’ayant pas compris le rôle de ce test, il est possible qu’une modification plus importante soit nécessaire.
#2 Mis à jour par Benjamin Bohard il y a presque 4 ans
diff --git a/creole/lint/ansiwriter.py b/creole/lint/ansiwriter.py index 59c547f8..d30a2156 100644 --- a/creole/lint/ansiwriter.py +++ b/creole/lint/ansiwriter.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """Simple API fro creolelint reports""" import sys +from functools import cmp_to_key from creole.lint.warning import Warn from creole.lint import warnsymb @@ -51,12 +52,12 @@ class AnsiWriter(object): ansi_print('') ansi_print('%s (%s:%s:%s)'%(warncomment, itemname, name, level), self.output) def compare(x,y): - return cmp(x[0],y[0]) + return (x > y) - (x < y) for vfile in dico_loc.keys(): if vfile != 'dictionnaire': ansi_print('%s\-- fichier %s' % (' '*ident, vfile), self.output, newline=False) vlines = dico_loc[vfile] - vlines.sort(compare) + vlines.sort(key=cmp_to_key(compare)) oldline=0 for vline, var in vlines: if hasattr(var, 'name'):
Changement pour un comportement identique.
https://docs.python.org/3.8/library/functions.html?highlight=cmp
https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
#3 Mis à jour par Benjamin Bohard il y a presque 4 ans
- Statut changé de Nouveau à En cours
#4 Mis à jour par Benjamin Bohard il y a presque 4 ans
- Assigné à mis à Benjamin Bohard
#5 Mis à jour par Benjamin Bohard il y a presque 4 ans
Et les problèmes traditionnels d’unicode VS str.
#6 Mis à jour par Benjamin Bohard il y a presque 4 ans
- Statut changé de En cours à Résolu
#7 Mis à jour par Joël Cuissinat il y a presque 4 ans
- Statut changé de Résolu à Fermé
- % réalisé changé de 0 à 100
- Restant à faire (heures) mis à 0.0
OK