From e31c2077cd15ed83f81974c2cc8729f093731da3 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Wed, 10 Apr 2024 11:44:25 -0400 Subject: [PATCH 01/15] Attempt to fix windows test --- manim/_config/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manim/_config/__init__.py b/manim/_config/__init__.py index 4f0bef5179..834983a052 100644 --- a/manim/_config/__init__.py +++ b/manim/_config/__init__.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +import os from contextlib import contextmanager from typing import Any, Generator @@ -20,6 +21,8 @@ "cli_ctx_settings", ] +os.environ["PYTHONIOENCODING"] = "utf-8" + parser = make_config_parser() # The logger can be accessed from anywhere as manim.logger, or as From ce005d35a3f3deb4dc82114d139488f90602ce74 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Wed, 10 Apr 2024 12:02:26 -0400 Subject: [PATCH 02/15] Revert "Attempt to fix windows test" This reverts commit e31c2077cd15ed83f81974c2cc8729f093731da3. --- manim/_config/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/manim/_config/__init__.py b/manim/_config/__init__.py index 834983a052..4f0bef5179 100644 --- a/manim/_config/__init__.py +++ b/manim/_config/__init__.py @@ -3,7 +3,6 @@ from __future__ import annotations import logging -import os from contextlib import contextmanager from typing import Any, Generator @@ -21,8 +20,6 @@ "cli_ctx_settings", ] -os.environ["PYTHONIOENCODING"] = "utf-8" - parser = make_config_parser() # The logger can be accessed from anywhere as manim.logger, or as From 1982a5892ee7c56b963937dc519937528f212ef2 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Wed, 10 Apr 2024 12:03:11 -0400 Subject: [PATCH 03/15] try a different fix --- manim/_config/logger_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manim/_config/logger_utils.py b/manim/_config/logger_utils.py index e17bc44b8c..0b1ed849e6 100644 --- a/manim/_config/logger_utils.py +++ b/manim/_config/logger_utils.py @@ -83,7 +83,7 @@ def make_logger( """ # Throughout the codebase, use console.print() instead of print() theme = parse_theme(parser) - console = Console(theme=theme) + console = Console(theme=theme, legacy_windows=False) error_console = Console(theme=theme, stderr=True) From 5c9ee86aca75b0c530910e5a585ec1c1b0295c02 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Wed, 10 Apr 2024 12:14:34 -0400 Subject: [PATCH 04/15] maybe both fixes together? --- manim/_config/logger_utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manim/_config/logger_utils.py b/manim/_config/logger_utils.py index 0b1ed849e6..f2602dc42d 100644 --- a/manim/_config/logger_utils.py +++ b/manim/_config/logger_utils.py @@ -15,6 +15,7 @@ import copy import json import logging +import os from typing import TYPE_CHECKING from rich import color, errors @@ -87,6 +88,9 @@ def make_logger( error_console = Console(theme=theme, stderr=True) + # fix encoding (some windows use cp1252) + os.environ["PYTHONIOENCODING"] = "utf-8" + # set the rich handler rich_handler = RichHandler( console=console, From 4779e406f676d0f34d8d65d6044e4bc2e31c26c0 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Wed, 10 Apr 2024 15:52:42 -0400 Subject: [PATCH 05/15] try adding in CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2a06b25cc..3f0a3124f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,7 @@ jobs: env: DISPLAY: :0 PYTEST_ADDOPTS: "--color=yes" # colors in pytest + PYTHONIOENCODING: "utf-8" strategy: fail-fast: false matrix: From cb1518e401319a634325e4f115671928288f9c1f Mon Sep 17 00:00:00 2001 From: adeshpande <110117391+JasonGrace2282@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:57:14 -0400 Subject: [PATCH 06/15] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f0a3124f7..8953268816 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: env: DISPLAY: :0 PYTEST_ADDOPTS: "--color=yes" # colors in pytest - PYTHONIOENCODING: "utf-8" + PYTHONIOENCODING: "utf16" strategy: fail-fast: false matrix: From 559f62579b6690b093a032ba9b4f1c00b9cd5896 Mon Sep 17 00:00:00 2001 From: adeshpande <110117391+JasonGrace2282@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:57:43 -0400 Subject: [PATCH 07/15] Update logger_utils.py --- manim/_config/logger_utils.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/manim/_config/logger_utils.py b/manim/_config/logger_utils.py index f2602dc42d..0b1ed849e6 100644 --- a/manim/_config/logger_utils.py +++ b/manim/_config/logger_utils.py @@ -15,7 +15,6 @@ import copy import json import logging -import os from typing import TYPE_CHECKING from rich import color, errors @@ -88,9 +87,6 @@ def make_logger( error_console = Console(theme=theme, stderr=True) - # fix encoding (some windows use cp1252) - os.environ["PYTHONIOENCODING"] = "utf-8" - # set the rich handler rich_handler = RichHandler( console=console, From d320d1445d5722bf61d0dc2e6adfbac9d4a15482 Mon Sep 17 00:00:00 2001 From: adeshpande <110117391+JasonGrace2282@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:09:20 -0400 Subject: [PATCH 08/15] maybe needs a dash? --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8953268816..93229ea246 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: env: DISPLAY: :0 PYTEST_ADDOPTS: "--color=yes" # colors in pytest - PYTHONIOENCODING: "utf16" + PYTHONIOENCODING: "utf-16" strategy: fail-fast: false matrix: From 18cdceef4529b324a7d1a403bdc6111ebc2ca0da Mon Sep 17 00:00:00 2001 From: adeshpande <110117391+JasonGrace2282@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:11:05 -0400 Subject: [PATCH 09/15] try utf8 again --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93229ea246..b750abb2b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: env: DISPLAY: :0 PYTEST_ADDOPTS: "--color=yes" # colors in pytest - PYTHONIOENCODING: "utf-16" + PYTHONIOENCODING: "utf8" strategy: fail-fast: false matrix: From b14675fd6d540087b650784ef2ff76ea4b0c7383 Mon Sep 17 00:00:00 2001 From: adeshpande <110117391+JasonGrace2282@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:12:38 -0400 Subject: [PATCH 10/15] Remove legacy_windows --- manim/_config/logger_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manim/_config/logger_utils.py b/manim/_config/logger_utils.py index 0b1ed849e6..e17bc44b8c 100644 --- a/manim/_config/logger_utils.py +++ b/manim/_config/logger_utils.py @@ -83,7 +83,7 @@ def make_logger( """ # Throughout the codebase, use console.print() instead of print() theme = parse_theme(parser) - console = Console(theme=theme, legacy_windows=False) + console = Console(theme=theme) error_console = Console(theme=theme, stderr=True) From b43f82d3564cc97fcfdfc65d9828fdc8e3721c89 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Thu, 11 Apr 2024 13:40:50 -0400 Subject: [PATCH 11/15] try changing test --- tests/test_logging/test_logging.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_logging/test_logging.py b/tests/test_logging/test_logging.py index 1bbc59de00..c4d8c8d6d3 100644 --- a/tests/test_logging/test_logging.py +++ b/tests/test_logging/test_logging.py @@ -43,9 +43,10 @@ def test_error_logging(tmp_path, python_version): str(path_error_scene), ] - _, err, exitcode = capture(command) - assert exitcode != 0 and len(err) > 0 - + out, err, exitcode = capture(command) + if err is None: + err = out + assert exitcode != 0 and "Traceback (most recent call last)" in err @logs_comparison( "bad_tex_scene_BadTex.txt", From 8a14f96ac603d23ca2a4ff92ca00b87f83be7e6f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:41:34 +0000 Subject: [PATCH 12/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_logging/test_logging.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_logging/test_logging.py b/tests/test_logging/test_logging.py index c4d8c8d6d3..ca209482a7 100644 --- a/tests/test_logging/test_logging.py +++ b/tests/test_logging/test_logging.py @@ -48,6 +48,7 @@ def test_error_logging(tmp_path, python_version): err = out assert exitcode != 0 and "Traceback (most recent call last)" in err + @logs_comparison( "bad_tex_scene_BadTex.txt", "logs/bad_tex_scene_BadTex.log", From a39440ad04466fbc66db92716a624e9b2fe9fb79 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Thu, 11 Apr 2024 14:03:58 -0400 Subject: [PATCH 13/15] Try decoding after capturing bytes output --- manim/utils/commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manim/utils/commands.py b/manim/utils/commands.py index 2ec9a776dd..6790446202 100644 --- a/manim/utils/commands.py +++ b/manim/utils/commands.py @@ -14,8 +14,8 @@ def capture(command, cwd=None, command_input=None): - p = run(command, cwd=cwd, input=command_input, capture_output=True, text=True) - out, err = p.stdout, p.stderr + p = run(command, cwd=cwd, input=command_input, capture_output=True) + out, err = p.stdout.decode('utf-8'), p.stderr.decode('utf-8') return out, err, p.returncode From 00200c6431c692df994011c25e50134e6b0b6121 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Thu, 11 Apr 2024 14:14:21 -0400 Subject: [PATCH 14/15] Nicer fix --- manim/utils/commands.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/manim/utils/commands.py b/manim/utils/commands.py index 6790446202..66c0c5f19a 100644 --- a/manim/utils/commands.py +++ b/manim/utils/commands.py @@ -14,8 +14,15 @@ def capture(command, cwd=None, command_input=None): - p = run(command, cwd=cwd, input=command_input, capture_output=True) - out, err = p.stdout.decode('utf-8'), p.stderr.decode('utf-8') + p = run( + command, + cwd=cwd, + input=command_input, + capture_output=True, + text=True, + encoding='utf-8' + ) + out, err = p.stdout, p.stderr return out, err, p.returncode From e133b79b288db850775a1534889745f84f962acd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 18:16:34 +0000 Subject: [PATCH 15/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- manim/utils/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manim/utils/commands.py b/manim/utils/commands.py index 66c0c5f19a..bcb205eb6a 100644 --- a/manim/utils/commands.py +++ b/manim/utils/commands.py @@ -20,7 +20,7 @@ def capture(command, cwd=None, command_input=None): input=command_input, capture_output=True, text=True, - encoding='utf-8' + encoding="utf-8", ) out, err = p.stdout, p.stderr return out, err, p.returncode