fix: PYBIND11_OBJECT required pybind11 namespace (regression) (#2553)

* fix: PYBIND11_OBJECT could only be used inside the pybind11 namespace (regression)

* docs: add changelog for conversion protection change

* ci: update to Python 3.9
This commit is contained in:
Henry Schreiner 2020-10-06 10:04:13 -04:00 committed by GitHub
parent 9a0c96dd4c
commit 00edc3001b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 20 deletions

View File

@ -22,6 +22,7 @@ jobs:
- 2.7 - 2.7
- 3.5 - 3.5
- 3.8 - 3.8
- 3.9
- pypy2 - pypy2
- pypy3 - pypy3
@ -32,34 +33,33 @@ jobs:
# We support three optional keys: args (both build), args1 (first # We support three optional keys: args (both build), args1 (first
# build), and args2 (second build). # build), and args2 (second build).
include: include:
# Just add a key
- runs-on: ubuntu-latest - runs-on: ubuntu-latest
python: 3.6 python: 3.6
arch: x64 arch: x64
args: > args: >
-DPYBIND11_FINDPYTHON=ON -DPYBIND11_FINDPYTHON=ON
- runs-on: windows-latest
python: 3.6
arch: x64
args: >
-DPYBIND11_FINDPYTHON=ON
- runs-on: ubuntu-latest
python: 3.8
arch: x64
args: >
-DPYBIND11_FINDPYTHON=ON
# New runs
- runs-on: windows-2016 - runs-on: windows-2016
python: 3.7 python: 3.7
arch: x86 arch: x86
args2: > args2: >
-DCMAKE_CXX_FLAGS="/permissive- /EHsc /GR" -DCMAKE_CXX_FLAGS="/permissive- /EHsc /GR"
- runs-on: windows-latest
python: 3.6
arch: x64
args: >
-DPYBIND11_FINDPYTHON=ON
- runs-on: windows-latest - runs-on: windows-latest
python: 3.7 python: 3.7
arch: x64 arch: x64
- runs-on: ubuntu-latest
python: 3.9-dev
arch: x64
- runs-on: macos-latest
python: 3.9-dev
arch: x64
args: >
-DPYBIND11_FINDPYTHON=ON
# These items will be removed from the build matrix, keys must match. # These items will be removed from the build matrix, keys must match.
exclude: exclude:
# Currently 32bit only, and we build 64bit # Currently 32bit only, and we build 64bit
@ -75,12 +75,11 @@ jobs:
python: 3.8 python: 3.8
arch: x64 arch: x64
- runs-on: windows-latest - runs-on: windows-latest
python: 3.9-dev python: 3.9
arch: x64 arch: x64
name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • ${{ matrix.arch }} ${{ matrix.args }}" name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • ${{ matrix.arch }} ${{ matrix.args }}"
runs-on: ${{ matrix.runs-on }} runs-on: ${{ matrix.runs-on }}
continue-on-error: ${{ endsWith(matrix.python, 'dev') }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -196,7 +195,7 @@ jobs:
- 3.9 - 3.9
- 5 - 5
- 7 - 7
- 9 - 10
- dev - dev
name: "🐍 3 • Clang ${{ matrix.clang }} • x64" name: "🐍 3 • Clang ${{ matrix.clang }} • x64"

View File

@ -126,6 +126,11 @@ Smaller or developer focused features:
* Throw if conversion to ``str`` fails. * Throw if conversion to ``str`` fails.
`#2477 <https://github.com/pybind/pybind11/pull/2477>`_ `#2477 <https://github.com/pybind/pybind11/pull/2477>`_
* Throw error if conversion to a pybind11 type if the Python object isn't a
valid instance of that type, such as ``py::bytes(o)`` when ``py::object o``
isn't a bytes instance.
`#2349 <https://github.com/pybind/pybind11/pull/2349>`_
* Pointer to ``std::tuple`` & ``std::pair`` supported in cast. * Pointer to ``std::tuple`` & ``std::pair`` supported in cast.
`#2334 <https://github.com/pybind/pybind11/pull/2334>`_ `#2334 <https://github.com/pybind/pybind11/pull/2334>`_

View File

@ -23,6 +23,10 @@ An error is now thrown when ``__init__`` is forgotten on subclasses. This was
incorrect before, but was not checked. Add a call to ``__init__`` if it is incorrect before, but was not checked. Add a call to ``__init__`` if it is
missing. missing.
A ``py::type_error`` is now thrown when casting to a subclass (like
``py::bytes`` from ``py::object``) if the conversion is not valid. Make a valid
conversion instead.
The undocumented ``h.get_type()`` method has been deprecated and replaced by The undocumented ``h.get_type()`` method has been deprecated and replaced by
``py::type::of(h)``. ``py::type::of(h)``.

View File

@ -813,8 +813,8 @@ PYBIND11_NAMESPACE_END(detail)
{ if (!m_ptr) throw error_already_set(); } { if (!m_ptr) throw error_already_set(); }
#define PYBIND11_OBJECT_CHECK_FAILED(Name, o) \ #define PYBIND11_OBJECT_CHECK_FAILED(Name, o) \
type_error("Object of type '" + \ ::pybind11::type_error("Object of type '" + \
pybind11::detail::get_fully_qualified_tp_name(Py_TYPE(o.ptr())) + \ ::pybind11::detail::get_fully_qualified_tp_name(Py_TYPE(o.ptr())) + \
"' is not an instance of '" #Name "'") "' is not an instance of '" #Name "'")
#define PYBIND11_OBJECT(Name, Parent, CheckFun) \ #define PYBIND11_OBJECT(Name, Parent, CheckFun) \