[schema2sql] encode string before passing it to md5

py3k only accepts a byte array here. Related to #267910.

authorJulien Cristau <julien.cristau@logilab.fr>
changeset479ac309ce46
branchdefault
phasedraft
hiddenyes
parent revision#ce5778c0bb73 [schema] don't redefine _
child revision#db5bd300381a [reader] don't use 3-expr raise syntax
files modified by this revision
schema2sql.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1413463184 -7200
# Thu Oct 16 14:39:44 2014 +0200
# Node ID 479ac309ce46c6b8a36a2fc72b00a36d99ec5553
# Parent ce5778c0bb7311cc0c5fd4a45884c3b8f8d7aad3
[schema2sql] encode string before passing it to md5

py3k only accepts a byte array here. Related to #267910.

diff --git a/schema2sql.py b/schema2sql.py
@@ -75,13 +75,13 @@
1                for rschema in eschema.subject_relations()
2                if not rschema.final and rschema.inlined]
3      return attrs
4 
5  def unique_index_name(eschema, columns):
6 -    return u'unique_%s' % md5(eschema.type +
7 +    return u'unique_%s' % md5((eschema.type +
8                                ',' +
9 -                              ','.join(sorted(columns))).hexdigest()
10 +                              ','.join(sorted(columns))).encode('ascii')).hexdigest()
11 
12  def iter_unique_index_names(eschema):
13      for columns in eschema._unique_together or ():
14          yield columns, unique_index_name(eschema, columns)
15