From d08b7e72c994d9bb4b4d7cc0e9b2220d441f1dbf Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 7 Apr 2024 21:15:34 +0300 Subject: [PATCH] gateway_base: fix `load(strconfig)` getting ignored Accidental regression in 2.1.0 (c58d485ff97d401dd02516cce). Fix #267. --- CHANGELOG.rst | 6 ++++++ src/execnet/gateway_base.py | 4 +--- testing/test_serializer.py | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a05344bf..8fee91e5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,9 @@ +TBD +--- + +* `#267 `__ Fixed regression + in 2.1.0 where the ``strconfig`` argument to ``load``/``loads`` is ignored. + 2.1.0 (2024-04-05) ------------------ diff --git a/src/execnet/gateway_base.py b/src/execnet/gateway_base.py index f5333064..9ba25b42 100644 --- a/src/execnet/gateway_base.py +++ b/src/execnet/gateway_base.py @@ -1391,9 +1391,7 @@ def __init__( gw: BaseGateway | None = channel_or_gateway.gateway else: gw = channel_or_gateway - if channel_or_gateway is None: - strconfig = None - else: + if channel_or_gateway is not None: strconfig = channel_or_gateway._strconfig if strconfig: self.py2str_as_py3str, self.py3str_as_py2str = strconfig diff --git a/testing/test_serializer.py b/testing/test_serializer.py index 64539399..aff41a98 100644 --- a/testing/test_serializer.py +++ b/testing/test_serializer.py @@ -163,3 +163,8 @@ def test_tuple_nested_with_empty_in_between(dump, load) -> None: tp, s = load(p) assert tp == "tuple" assert s == "(1, (), 3)" + + +def test_py2_string_loads() -> None: + """Regression test for #267.""" + assert execnet.loads(b"\x02M\x00\x00\x00\x01aQ") == b"a"