Projet

Général

Profil

Bug #1479

FutureWarning with python2.7 (elementtree)

Ajouté par Thomas Noël il y a presque 12 ans. Mis à jour il y a plus de 9 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
-
Catégorie:
-
Version cible:
Début:
30 mai 2012
Echéance:
% réalisé:

90%

Temps estimé:
Patch proposed:
Planning:

Description

Doing a sync-metadata with python2.7 :

/usr/local/univnautes/lib/python2.7/site-packages/authentic2/saml/management/commands/sync-metadata.py:35: FutureWarning: The behavior of this method will change in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.
  if organization:
/usr/local/univnautes/lib/python2.7/site-packages/authentic2/saml/management/commands/sync-metadata.py:38: FutureWarning: The behavior of this method will change in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.
  org = organization_display_name or organization_name

A patch could be:

--- a/authentic2/saml/management/commands/sync-metadata.py
+++ b/authentic2/saml/management/commands/sync-metadata.py
@@ -32,12 +32,13 @@ def load_one_entity(tree, options, sp_policy=None, idp_policy=None):
     entity_id = tree.get(ENTITY_ID)
     organization = tree.find(ORGANIZATION)
     name, org = None, None
-    if organization:
+    if organization is not None:
         organization_display_name = organization.find(ORGANIZATION_DISPLAY_NAME)
         organization_name = organization.find(ORGANIZATION_NAME)
-        org = organization_display_name or organization_name
-        if org is not None:
-            name = org.text
+        if organization_display_name is not None:
+            name = organization_display_name.text
+        elif organization_name is not None:
+            name = organization_name.text
     if not name:
         name = entity_id
     idp, sp = False, False

Révisions associées

Révision e819eb7e (diff)
Ajouté par Benjamin Dauvergne il y a presque 12 ans

element tree node can be equivalent to False, add explicit None test

Patch submitted by Thomas Noël

Fixes #1479

Historique

#1

Mis à jour par Benjamin Dauvergne il y a presque 12 ans

  • Statut changé de Nouveau à Solution déployée
  • % réalisé changé de 0 à 90
#2

Mis à jour par Benjamin Dauvergne il y a plus de 9 ans

  • Statut changé de Solution déployée à Fermé

Formats disponibles : Atom PDF