2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-22 01:46:15 +01:00

Fix and test for class names containing utf-8 characters - Python 2.7 and 3.x

This commit is contained in:
Thomas Nagy 2015-01-06 12:29:06 +01:00
parent 6d674de8c9
commit 1551b070b2
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
2 changed files with 7 additions and 10 deletions

View File

@ -53,7 +53,7 @@ def build(bld):
bld(features='subst', fun=hlink, source='wscript', target='wscript3')
# this one is just a reminder that simple files can be created (and a test too)
#bld(rule='echo "การไฟ่" > ${TGT}', target='foo.txt')
bld(rule='echo "การไฟ่" > ${TGT}', target='foo.txt')
# and this is an alternate syntax
#@bld.rule(source='wscript', target='wscript2')

View File

@ -94,6 +94,9 @@ class store_task_type(type):
# getattr(cls, 'hcode') would look in the upper classes
cls.hcode = Utils.h_fun(cls.run)
if sys.hexversion > 0x3000000:
cls.hcode = cls.hcode.encode('iso8859-1', 'xmlcharrefreplace')
# be creative
getattr(cls, 'register', classes)[name] = cls
@ -546,7 +549,7 @@ class Task(TaskBase):
except AttributeError: pass
self.m = Utils.md5()
self.m.update(self.hcode.encode())
self.m.update(self.hcode)
# explicit deps
self.sig_explicit_deps()
@ -833,15 +836,9 @@ if sys.hexversion > 0x3000000:
except AttributeError:
m = Utils.md5()
up = m.update
def encode_and_update(path):
try:
up(path.encode('iso8859-1'))
except UnicodeEncodeError as e:
Logs.error("Can't encode in iso8859-1: %s" % path)
raise e
encode_and_update(self.__class__.__name__)
up(self.__class__.__name__.encode('iso8859-1', 'xmlcharrefreplace'))
for x in self.inputs + self.outputs:
encode_and_update(x.abspath())
up(x.abspath().encode('iso8859-1', 'xmlcharrefreplace'))
self.uid_ = m.digest()
return self.uid_
uid.__doc__ = Task.uid.__doc__