From eb44788be05d830bb6cae2a5e165ec15d43186eb Mon Sep 17 00:00:00 2001 From: mattip Date: Thu, 18 Nov 2021 17:13:47 +0200 Subject: [PATCH 1/4] skip printing value to stdout on PyPy --- src/encoding_decoding.cpp | 7 +++++++ tests/python-tests/test_api.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/encoding_decoding.cpp b/src/encoding_decoding.cpp index 530dfa6..b5e88dc 100644 --- a/src/encoding_decoding.cpp +++ b/src/encoding_decoding.cpp @@ -74,7 +74,14 @@ toml::array py_list_to_toml_array(const py::list &list) { arr.push_back(time_value); } else { std::stringstream ss; +#ifdef PYPY_VERSION + // see https://github.com/conda-forge/pytomlpp-feedstock/pull/1#issuecomment-972738986 + // and https://github.com/pybind/pybind11/issues/3408#issuecomment-972752210 + ss << "not a valid type for conversion " << std::endl; +#else ss << "not a valid type for conversion " << it << std::endl; +#endif + std::cout << "uhoh, bad type" << std::endl; throw py::type_error(ss.str()); } } diff --git a/tests/python-tests/test_api.py b/tests/python-tests/test_api.py index 8a65c1b..c2eadaf 100644 --- a/tests/python-tests/test_api.py +++ b/tests/python-tests/test_api.py @@ -117,6 +117,8 @@ class A: pass with pytest.raises(TypeError): pytomlpp.dumps({'a': A()}) + with pytest.raises(TypeError): + pytomlpp.dumps({'a': [A()]}) @pytest.mark.parametrize("toml_file", valid_toml_files) def test_decode_encode_binary(toml_file, tmp_path): From fb50f21bbf49a4cb535ae24bee91310029101839 Mon Sep 17 00:00:00 2001 From: mattip Date: Thu, 18 Nov 2021 17:14:51 +0200 Subject: [PATCH 2/4] add builds for pypy --- .github/workflows/dists.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dists.yml b/.github/workflows/dists.yml index 17d7ae7..3f1a11f 100644 --- a/.github/workflows/dists.yml +++ b/.github/workflows/dists.yml @@ -55,10 +55,10 @@ jobs: - name: Build wheels env: - # Skip building on Python 2.7 and PyPy + # Skip building on Python 2.7 # Additionally, skip 32-bit Windows for now as MSVC needs seperate setup with different toolchain to do this # Refer: https://cibuildwheel.readthedocs.io/en/stable/cpp_standards/#windows-and-python-27 - CIBW_SKIP: cp27-* pp* *-win32 cp35-* + CIBW_SKIP: cp27-* *-win32 cp35-* CIBW_BEFORE_TEST: pip install -r tests/requirements.txt CIBW_TEST_COMMAND: pytest {project}/tests CIBW_ARCHS_MACOS: "x86_64 universal2 arm64" # build on M1 chip From 53184c23962e78fdbec0a7007bec1f3fe1a3261c Mon Sep 17 00:00:00 2001 From: mattip Date: Thu, 18 Nov 2021 21:13:18 +0200 Subject: [PATCH 3/4] fixes from review, linter --- src/encoding_decoding.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/encoding_decoding.cpp b/src/encoding_decoding.cpp index b5e88dc..0af4836 100644 --- a/src/encoding_decoding.cpp +++ b/src/encoding_decoding.cpp @@ -75,13 +75,14 @@ toml::array py_list_to_toml_array(const py::list &list) { } else { std::stringstream ss; #ifdef PYPY_VERSION - // see https://github.com/conda-forge/pytomlpp-feedstock/pull/1#issuecomment-972738986 - // and https://github.com/pybind/pybind11/issues/3408#issuecomment-972752210 + // see + // https://github.com/conda-forge/pytomlpp-feedstock/pull/1#issuecomment-972738986 + // and + // https://github.com/pybind/pybind11/issues/3408#issuecomment-972752210 ss << "not a valid type for conversion " << std::endl; #else ss << "not a valid type for conversion " << it << std::endl; #endif - std::cout << "uhoh, bad type" << std::endl; throw py::type_error(ss.str()); } } From bc4d4cab419d0768dbda7160b5cc139d71d57be4 Mon Sep 17 00:00:00 2001 From: mattip Date: Thu, 18 Nov 2021 21:15:53 +0200 Subject: [PATCH 4/4] fix linter --- src/encoding_decoding.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/encoding_decoding.cpp b/src/encoding_decoding.cpp index 0af4836..0c78830 100644 --- a/src/encoding_decoding.cpp +++ b/src/encoding_decoding.cpp @@ -75,9 +75,9 @@ toml::array py_list_to_toml_array(const py::list &list) { } else { std::stringstream ss; #ifdef PYPY_VERSION - // see + // see // https://github.com/conda-forge/pytomlpp-feedstock/pull/1#issuecomment-972738986 - // and + // and // https://github.com/pybind/pybind11/issues/3408#issuecomment-972752210 ss << "not a valid type for conversion " << std::endl; #else