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

View File

@ -126,6 +126,11 @@ Smaller or developer focused features:
* Throw if conversion to ``str`` fails.
`#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.
`#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
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
``py::type::of(h)``.

View File

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