Skip to content

Commit

Permalink
Add PyPy to the build matrix and adapt for pypy pybind11 issue (#61)
Browse files Browse the repository at this point in the history
* skip printing value to stdout on PyPy

* add builds for pypy

* fixes from review, linter

* fix linter
  • Loading branch information
mattip authored Nov 18, 2021
1 parent 1cc2c01 commit 9dbe2f5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/encoding_decoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,15 @@ 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
throw py::type_error(ss.str());
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/python-tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 9dbe2f5

Please sign in to comment.