• Raul Tambre's avatar
    ukm: Encode string before hashing · 36c8ca99
    Raul Tambre authored
    In Python 3 only bytes objects can be hashed. This means we need to encode() beforehand.
    Python 2 doesn't care, so this way it works on both.
    
    Traceback (most recent call last):
      File "../../tools/metrics/ukm/gen_builders.py", line 35, in <module>
        sys.exit(main(sys.argv))
      File "../../tools/metrics/ukm/gen_builders.py", line 29, in main
        builders_template.WriteFiles(args.output, relpath, data)
      File "C:\Google\chromium\src\tools\metrics\ukm\builders_template.py", line 93, in WriteFiles
        HEADER.WriteFile(outdir, relpath, data)
      File "C:\Google\chromium\src\tools\metrics\ukm\codegen.py", line 89, in WriteFile
        output.write(self._StampFileCode(relpath, data))
      File "C:\Google\chromium\src\tools\metrics\ukm\codegen.py", line 73, in _StampFileCode
        event_code = "".join(
      File "C:\Google\chromium\src\tools\metrics\ukm\codegen.py", line 74, in <genexpr>
        self._StampEventCode(file_info, event)
      File "C:\Google\chromium\src\tools\metrics\ukm\codegen.py", line 62, in _StampEventCode
        event_info = EventInfo(event)
      File "C:\Google\chromium\src\tools\metrics\ukm\codegen.py", line 36, in __init__
        self.hash = HashName(json_obj['name'])
      File "C:\Google\chromium\src\tools\metrics\ukm\codegen.py", line 23, in HashName
        return struct.unpack('>Q', hashlib.md5(name).digest()[:8])[0]
    TypeError: Unicode-objects must be encoded before hashing
    
    Bug: 941669
    Change-Id: I063ed268a8326b5acedbddc2628af7b015edb7cd
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2082551Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
    Commit-Queue: Raul Tambre <raul@tambre.ee>
    Auto-Submit: Raul Tambre <raul@tambre.ee>
    Cr-Commit-Position: refs/heads/master@{#756295}
    36c8ca99
BUILD.gn 4.84 KB