From a7325250841e4ea8cefa4052b0497d935a384721 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Fri, 13 Nov 2020 19:04:02 +0000 Subject: [PATCH] Move encoding switch to before the unicode decision is made --- cibuildwheel/__main__.py | 5 ----- cibuildwheel/logger.py | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 86ea12f0..4e25befa 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -54,11 +54,6 @@ def strtobool(val: str) -> bool: def main() -> None: - if sys.platform == 'win32' and hasattr(sys.stdout, 'reconfigure'): - # the encoding on Windows can be a 1-byte charmap, but all CIs support - # utf8, so we hardcode that - sys.stdout.reconfigure(encoding='utf8') - parser = argparse.ArgumentParser( description='Build wheels for all the platforms.', epilog=''' diff --git a/cibuildwheel/logger.py b/cibuildwheel/logger.py index 5dbf3631..66e84f20 100644 --- a/cibuildwheel/logger.py +++ b/cibuildwheel/logger.py @@ -34,6 +34,11 @@ class Logger: active_fold_group_name: Optional[str] = None def __init__(self): + if sys.platform == 'win32' and hasattr(sys.stdout, 'reconfigure'): + # the encoding on Windows can be a 1-byte charmap, but all CIs + # support utf8, so we hardcode that + sys.stdout.reconfigure(encoding='utf8') + self.unicode_enabled = file_supports_unicode(sys.stdout) if 'AZURE_HTTP_USER_AGENT' in os.environ: