[yoda-svn] yoda: More py3 fixes. Tests work

YODA Mercurial yoda at projects.hepforge.org
Fri Nov 17 14:00:01 GMT 2017


details:   https://yoda.hepforge.org/hg/yoda/rev/e071ac260713
branches:  
changeset: 1430:e071ac260713
user:      David Grellscheid <david.grellscheid at durham.ac.uk>
date:      Fri Nov 17 13:45:02 2017 +0000
description:
More py3 fixes. Tests work

diffs (truncated from 417 to 50 lines):

--- a/pyext/yoda/include/AnalysisObject.pyx	Fri Nov 17 10:40:30 2017 +0000
+++ b/pyext/yoda/include/AnalysisObject.pyx	Fri Nov 17 13:45:02 2017 +0000
@@ -45,14 +45,14 @@
         # TODO: add a map equivalent to C++?
         return dict((k.lower(), self.annotation(k)) for k in self.annotations)
 
-    def annotation(self, string k, default=None):
+    def annotation(self, k, default=None):
         """Get annotation k from this object (falling back to default if not set).
 
         The annotation string will be automatically converted to Python
         native types as far as possible -- more complex types are possible
         if the yaml module is installed."""
         try:
-            astr = self.aoptr().annotation(string(k))
+            astr = self.aoptr().annotation(<string>k.encode('utf-8'))
             try:
                 import yaml
                 return yaml.load(astr)
@@ -61,17 +61,18 @@
         except:
             return default
 
-    def setAnnotation(self, string k, v):
+    def setAnnotation(self, k, v):
         """Set annotation k on this object."""
-        self.aoptr().setAnnotation(k, util._autostr(v))
+        self.aoptr().setAnnotation(<string>k.encode('utf-8'), 
+                                   <string>util._autostr(v).encode('utf-8'))
 
-    def hasAnnotation(self, string k):
+    def hasAnnotation(self, k):
         """Check if this object has annotation k."""
-        return self.aoptr().hasAnnotation(string(k))
+        return self.aoptr().hasAnnotation(<string>k.encode('utf-8'))
 
-    def rmAnnotation(self, string k):
+    def rmAnnotation(self, k):
         """Remove annotation k from this object."""
-        self.aoptr().rmAnnotation(string(k))
+        self.aoptr().rmAnnotation(<string>k.encode('utf-8'))
 
     def clearAnnotations(self):
         """Clear the annotations dictionary."""
@@ -92,7 +93,7 @@
         """
         Return the histogram name, i.e. the last part of the path (which may be empty).
         """
-        return self.aoptr().name().c_str()
+        return self.aoptr().name().c_str().decode('utf-8')


More information about the yoda-svn mailing list