[Mesa-dev] [PATCH 15/26] python: Specify the template output encoding
Dylan Baker
dylan at pnwbakers.com
Tue Aug 7 20:28:11 UTC 2018
Reviewed-by: Dylan Baker <dylan at pnwbakers.com>
Quoting Mathieu Bridon (2018-07-05 06:17:46)
> We're trying to write a unicode string (i.e decoded) to a file opened
> in binary (i.e encoded) mode.
>
> In Python 2 this works, because of the automatic conversion between
> byte and unicode strings.
>
> In Python 3 this fails though, as no automatic conversion is attempted.
>
> This change makes the scripts compatible with both versions of Python.
>
> Signed-off-by: Mathieu Bridon <bochecha at daitauha.fr>
> ---
> src/compiler/nir/nir_intrinsics_c.py | 2 +-
> src/compiler/nir/nir_intrinsics_h.py | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/nir/nir_intrinsics_c.py b/src/compiler/nir/nir_intrinsics_c.py
> index 98af67c38a..ac45b94d49 100644
> --- a/src/compiler/nir/nir_intrinsics_c.py
> +++ b/src/compiler/nir/nir_intrinsics_c.py
> @@ -64,7 +64,7 @@ def main():
>
> path = os.path.join(args.outdir, 'nir_intrinsics.c')
> with open(path, 'wb') as f:
> - f.write(Template(template).render(INTR_OPCODES=INTR_OPCODES))
> + f.write(Template(template, output_encoding='utf-8').render(INTR_OPCODES=INTR_OPCODES))
>
> if __name__ == '__main__':
> main()
> diff --git a/src/compiler/nir/nir_intrinsics_h.py b/src/compiler/nir/nir_intrinsics_h.py
> index 8a4f0d501e..8abc6a8626 100644
> --- a/src/compiler/nir/nir_intrinsics_h.py
> +++ b/src/compiler/nir/nir_intrinsics_h.py
> @@ -53,7 +53,7 @@ def main():
>
> path = os.path.join(args.outdir, 'nir_intrinsics.h')
> with open(path, 'wb') as f:
> - f.write(Template(template).render(INTR_OPCODES=INTR_OPCODES))
> + f.write(Template(template, output_encoding='utf-8').render(INTR_OPCODES=INTR_OPCODES))
>
> if __name__ == '__main__':
> main()
> --
> 2.17.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180807/18817224/attachment-0001.sig>
More information about the mesa-dev
mailing list