[PATCH 2 of 3 saem_ref] Fix UnicodeDecodeError when creating default ARK NAA

Denis Laxalde denis.laxalde at logilab.fr
Wed Feb 6 10:06:34 CET 2019


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1548144908 -3600
#      Tue Jan 22 09:15:08 2019 +0100
# Node ID d920b7551f920cef164167d22d1809db1b6c0b00
# Parent  5250523a788711581052e770067e2dafca53f266
# Available At http://hg.logilab.org/review/cubes/saem_ref
#              hg pull http://hg.logilab.org/review/cubes/saem_ref -r d920b7551f92
Fix UnicodeDecodeError when creating default ARK NAA

If "who" contains non-ascii characters, just calling text_type()
will fail and we need to specify the encoding.

diff --git a/cubicweb_saem_ref/__init__.py b/cubicweb_saem_ref/__init__.py
--- a/cubicweb_saem_ref/__init__.py
+++ b/cubicweb_saem_ref/__init__.py
@@ -84,6 +84,6 @@ def _nohook_store_factory(cnx, config):
 
 def create_default_naa(cnx, who, what):
     if not isinstance(who, text_type):
-        who = text_type(who)
+        who = text_type(who, 'utf-8')
     return cnx.create_entity('ArkNameAssigningAuthority',
                              who=who, what=what)



More information about the saem-devel mailing list