From ab2660af8b78cd832ddd8ee328cccd061730eda4 Mon Sep 17 00:00:00 2001 From: Vojtech Horky Date: Fri, 6 Oct 2023 14:14:04 +0200 Subject: [PATCH] [GR-47806] toml module cannot handle binary input --- mx.py | 2 +- mx_codeowners.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mx.py b/mx.py index 361e4d6c..869158c9 100755 --- a/mx.py +++ b/mx.py @@ -18831,7 +18831,7 @@ def alarm_handler(signum, frame): abort(1, killsig=signal.SIGINT) # The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue -version = VersionSpec("6.51.0") # GR-49282 mx cmake features and tar.bz2 support +version = VersionSpec("6.51.1") # GR-47806 Code owners: fix toml module use _mx_start_datetime = datetime.utcnow() _last_timestamp = _mx_start_datetime diff --git a/mx_codeowners.py b/mx_codeowners.py index e4cfafde..a91d0dca 100644 --- a/mx_codeowners.py +++ b/mx_codeowners.py @@ -55,7 +55,10 @@ def _load_toml_from_fd(fd): try: import toml try: - return toml.load(fd) + # This is kind of confusing because tomllib expects 'rb', + # toml expects 'rt' mode when reading from a file and for + # mx_stoml we also decode from UTF-8 ourselves explicitly. + return toml.loads(fd.read().decode('utf-8')) except toml.TomlDecodeError as e: raise _TomlParsingException(e) except ImportError: