diff --git a/CHANGELOG.md b/CHANGELOG.md index a4fb679ec..eb2c1a1ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,8 +22,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix NO_COLOR support on legacy Windows https://github.com/Textualize/rich/pull/2458 - Fix pretty printer handling of cyclic references https://github.com/Textualize/rich/pull/2524 - Fix missing `mode` property on file wrapper breaking uploads via `requests` https://github.com/Textualize/rich/pull/2495 +- Fix mismatching default value of parameter `ensure_ascii` https://github.com/Textualize/rich/pull/2538 - Remove unused height parameter in `Layout` class https://github.com/Textualize/rich/pull/2540 + ### Changed - Removed border from code blocks in Markdown diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1972229ab..155fb61bc 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -55,3 +55,4 @@ The following people have contributed to the development of Rich: - [Motahhar Mokfi](https://github.com/motahhar) - [Tomer Shalev](https://github.com/tomers) - [Serkan UYSAL](https://github.com/uysalserkan) +- [Zhe Huang](https://github.com/onlyacat) \ No newline at end of file diff --git a/rich/__init__.py b/rich/__init__.py index 6658707fa..b631d5449 100644 --- a/rich/__init__.py +++ b/rich/__init__.py @@ -81,7 +81,7 @@ def print_json( indent: Union[None, int, str] = 2, highlight: bool = True, skip_keys: bool = False, - ensure_ascii: bool = True, + ensure_ascii: bool = False, check_circular: bool = True, allow_nan: bool = True, default: Optional[Callable[[Any], Any]] = None, diff --git a/rich/console.py b/rich/console.py index 974a4e310..90034913d 100644 --- a/rich/console.py +++ b/rich/console.py @@ -1722,7 +1722,7 @@ def print_json( indent: Union[None, int, str] = 2, highlight: bool = True, skip_keys: bool = False, - ensure_ascii: bool = True, + ensure_ascii: bool = False, check_circular: bool = True, allow_nan: bool = True, default: Optional[Callable[[Any], Any]] = None, diff --git a/rich/json.py b/rich/json.py index 1fc115a95..ed9ca1ea5 100644 --- a/rich/json.py +++ b/rich/json.py @@ -27,7 +27,7 @@ def __init__( indent: Union[None, int, str] = 2, highlight: bool = True, skip_keys: bool = False, - ensure_ascii: bool = True, + ensure_ascii: bool = False, check_circular: bool = True, allow_nan: bool = True, default: Optional[Callable[[Any], Any]] = None, @@ -56,7 +56,7 @@ def from_data( indent: Union[None, int, str] = 2, highlight: bool = True, skip_keys: bool = False, - ensure_ascii: bool = True, + ensure_ascii: bool = False, check_circular: bool = True, allow_nan: bool = True, default: Optional[Callable[[Any], Any]] = None, diff --git a/tests/test_console.py b/tests/test_console.py index 369f0a67e..4509f6b2d 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -240,6 +240,15 @@ def test_print_json_ensure_ascii(): assert result == expected +def test_print_json_with_default_ensure_ascii(): + console = Console(file=io.StringIO(), color_system="truecolor") + console.print_json(data={"foo": "💩"}) + result = console.file.getvalue() + print(repr(result)) + expected = '\x1b[1m{\x1b[0m\n \x1b[1;34m"foo"\x1b[0m: \x1b[32m"💩"\x1b[0m\n\x1b[1m}\x1b[0m\n' + assert result == expected + + def test_print_json_indent_none(): console = Console(file=io.StringIO(), color_system="truecolor") data = {"name": "apple", "count": 1}