[py3k] bytes required for hashlib.{md5,sha1}()
authorRémi Cardona <remi.cardona@logilab.fr>
Tue, 13 Oct 2015 16:57:09 +0200
changeset 10671 e08102f45237
parent 10670 96380c1524b0
child 10672 f6f425a54a8d
[py3k] bytes required for hashlib.{md5,sha1}()
cwconfig.py
devtools/__init__.py
entities/adapters.py
hooks/syncschema.py
server/schema2sql.py
web/request.py
web/views/staticcontrollers.py
--- a/cwconfig.py	Thu Oct 01 11:40:23 2015 +0200
+++ b/cwconfig.py	Tue Oct 13 16:57:09 2015 +0200
@@ -1110,7 +1110,7 @@
             version = self.cube_version(pkg)
             infos.append('%s-%s' % (pkg, version))
         infos.append('cubicweb-%s' % str(self.cubicweb_version()))
-        return md5(';'.join(infos)).hexdigest()
+        return md5((';'.join(infos)).encode('ascii')).hexdigest()
 
     def load_configuration(self, **kw):
         """load instance's configuration files"""
--- a/devtools/__init__.py	Thu Oct 01 11:40:23 2015 +0200
+++ b/devtools/__init__.py	Tue Oct 13 16:57:09 2015 +0200
@@ -679,7 +679,7 @@
 
     @property
     def _config_id(self):
-        return sha1(self.config.apphome).hexdigest()[:10]
+        return sha1(self.config.apphome.encode('utf-8')).hexdigest()[:10]
 
     def _backup_name(self, db_id): # merge me with parent
         backup_name = '_'.join(('cache', self._config_id, self.dbname, db_id))
--- a/entities/adapters.py	Thu Oct 01 11:40:23 2015 +0200
+++ b/entities/adapters.py	Tue Oct 13 16:57:09 2015 +0200
@@ -386,7 +386,7 @@
         for rschema, attrschema in eschema.attribute_definitions():
             rdef = rschema.rdef(eschema, attrschema)
             for constraint in rdef.constraints:
-                if cstrname == 'cstr' + md5(eschema.type + rschema.type + constraint.type() + (constraint.serialize() or '')).hexdigest():
+                if cstrname == 'cstr' + md5((eschema.type + rschema.type + constraint.type() + (constraint.serialize() or '')).encode('ascii')).hexdigest():
                     break
             else:
                 continue
--- a/hooks/syncschema.py	Thu Oct 01 11:40:23 2015 +0200
+++ b/hooks/syncschema.py	Tue Oct 13 16:57:09 2015 +0200
@@ -769,8 +769,8 @@
             self.unique_changed = True
         if cstrtype in ('BoundaryConstraint', 'IntervalBoundConstraint', 'StaticVocabularyConstraint'):
             if oldcstr is not None:
-                oldcstrname = 'cstr' + md5(rdef.subject.type + rdef.rtype.type + cstrtype +
-                                           (self.oldcstr.serialize() or '')).hexdigest()
+                oldcstrname = 'cstr' + md5((rdef.subject.type + rdef.rtype.type + cstrtype +
+                                            (self.oldcstr.serialize() or '')).encode('ascii')).hexdigest()
                 cnx.system_sql('ALTER TABLE %s%s DROP CONSTRAINT %s' %
                                (SQL_PREFIX, rdef.subject.type, oldcstrname))
             cstrname, check = y2sql.check_constraint(rdef.subject, rdef.object, rdef.rtype.type,
--- a/server/schema2sql.py	Thu Oct 01 11:40:23 2015 +0200
+++ b/server/schema2sql.py	Tue Oct 13 16:57:09 2015 +0200
@@ -162,8 +162,8 @@
 
 def check_constraint(eschema, aschema, attr, constraint, dbhelper, prefix=''):
     # XXX should find a better name
-    cstrname = 'cstr' + md5(eschema.type + attr + constraint.type() +
-                            (constraint.serialize() or '')).hexdigest()
+    cstrname = 'cstr' + md5((eschema.type + attr + constraint.type() +
+                             (constraint.serialize() or '')).encode('ascii')).hexdigest()
     if constraint.type() == 'BoundaryConstraint':
         value = as_sql(constraint.boundary, dbhelper, prefix)
         return cstrname, '%s%s %s %s' % (prefix, attr, constraint.operator, value)
--- a/web/request.py	Thu Oct 01 11:40:23 2015 +0200
+++ b/web/request.py	Tue Oct 13 16:57:09 2015 +0200
@@ -52,7 +52,7 @@
 _MARKER = object()
 
 def build_cb_uid(seed):
-    sha = sha1('%s%s%s' % (time.time(), seed, random.random()))
+    sha = sha1(('%s%s%s' % (time.time(), seed, random.random())).encode('ascii'))
     return 'cb_%s' % (sha.hexdigest())
 
 
--- a/web/views/staticcontrollers.py	Thu Oct 01 11:40:23 2015 +0200
+++ b/web/views/staticcontrollers.py	Tue Oct 13 16:57:09 2015 +0200
@@ -140,7 +140,7 @@
         """return the filepath that will be used to cache concatenation of `paths`
         """
         _, ext = osp.splitext(paths[0])
-        fname = 'cache_concat_' + hashlib.md5(';'.join(paths)).hexdigest() + ext
+        fname = 'cache_concat_' + hashlib.md5((';'.join(paths)).encode('ascii')).hexdigest() + ext
         return osp.join(self.config.appdatahome, 'uicache', fname)
 
     def concat_cached_filepath(self, paths):