1. 06 Apr, 2019 1 commit
    • Henry Schreiner's avatar
      CI fixes (#1744) · ae951ca0
      Henry Schreiner authored
      * Fix warning that not including a cmake source or build dir will be a fatal error (it is now on newest CMakes)
          * Fixes appveyor
      * Travis uses CMake 3.9 for more than a year now
      * Travis dropped sudo: false in December
      * Dropping Sphinx 2
      - clang7: Suppress self-assign warnings; fix missing virtual dtors
      - pypy:
        - Keep old version (newer stuff breaks)
        - Pin packages to extra index for speed
      - travis:
        - Make docker explicit; remove docker if not needed
        - Make commands more verbose (for debugging / repro)
        - Make Ubuntu dist explicit per job
      - Fix Windows
      - Add names to travis
      ae951ca0
  2. 04 Feb, 2019 3 commits
  3. 03 Jan, 2019 1 commit
  4. 01 Dec, 2018 1 commit
  5. 16 Nov, 2018 1 commit
    • voxmea's avatar
      Adds type_caster support for std::deque. (#1609) · 17983e74
      voxmea authored
      * Adds std::deque to the types supported by list_caster in stl.h.
      * Adds a new test_deque test in test_stl.{py,cpp}.
      * Updates the documentation to include std::deque as a default
        supported type.
      17983e74
  6. 11 Nov, 2018 2 commits
    • Trevor Laughlin's avatar
      Enable unique_ptr holder with mixed Deleters between base and derived types (#1353) · 63c2a972
      Trevor Laughlin authored
      * Check default holder
      
      -Recognize "std::unique_ptr<T, D>" as a default holder even if "D" doesn't match between base and derived holders
      
      * Add test for unique_ptr<T, D> change
      63c2a972
    • Wenzel Jakob's avatar
      fix py::cast<void *> (#1605) · cea42467
      Wenzel Jakob authored
      Pybind11 provides a cast operator between opaque void* pointers on the
      C++ side and capsules on the Python side. The py::cast<void *>
      expression was not aware of this possibility and incorrectly triggered a
      compile-time assertion ("Unable to cast type to reference: value is
      local to type caster") that is now fixed.
      cea42467
  7. 09 Nov, 2018 3 commits
  8. 24 Oct, 2018 1 commit
  9. 11 Oct, 2018 1 commit
    • Allan Leal's avatar
      Fix for Issue #1258 (#1298) · e76dff77
      Allan Leal authored
      * Fix for Issue #1258
      
      list_caster::load method will now check for a Python string and prevent its automatic conversion to a list.
      This should fix the issue "pybind11/stl.h converts string to vector<string> #1258" (https://github.com/pybind/pybind11/issues/1258)
      
      * Added tests for fix of issue #1258
      
      * Changelog: stl string auto-conversion
      e76dff77
  10. 02 Oct, 2018 1 commit
  11. 25 Sep, 2018 1 commit
    • oremanj's avatar
      Fix potential crash when calling an overloaded function (#1327) · e7761e33
      oremanj authored
      * Fix potential crash when calling an overloaded function
      
      The crash would occur if:
      - dispatcher() uses two-pass logic (because the target is overloaded and some arguments support conversions)
      - the first pass (with conversions disabled) doesn't find any matching overload
      - the second pass does find a matching overload, but its return value can't be converted to Python
      
      The code for formatting the error message assumed `it` still pointed to the selected overload,
      but during the second-pass loop `it` was nullptr. Fix by setting `it` correctly if a second-pass
      call returns a nullptr `handle`. Add a new test that segfaults without this fix.
      
      * Make overload iteration const-correct so we don't have to iterate again on second-pass error
      
      * Change test_error_after_conversions dependencies to local classes/variables
      e7761e33
  12. 11 Sep, 2018 5 commits
    • Wenzel Jakob's avatar
      enum_: move most functionality to a non-template implementation · f4245181
      Wenzel Jakob authored
      This commit addresses an inefficiency in how enums are created in
      pybind11. Most of the enum_<> implementation is completely generic --
      however, being a template class, it ended up instantiating vast amounts
      of essentially identical code in larger projects with many enums.
      
      This commit introduces a generic non-templated helper class that is
      compatible with any kind of enumeration. enum_ then becomes a thin
      wrapper around this new class.
      
      The new enum_<> API is designed to be 100% compatible with the old one.
      f4245181
    • Wenzel Jakob's avatar
      relax operator[] for tuples, lists, and sequences · b4b22924
      Wenzel Jakob authored
      object_api::operator[] has a powerful overload for py::handle that can
      accept slices, tuples (for NumPy), etc.
      
      Lists, sequences, and tuples provide their own specialized operator[],
      which unfortunately disables this functionality. This is accidental, and
      the purpose of this commit is to re-enable the more general behavior.
      
      This commit is tangentially related to the previous one in that it makes
      py::handle/py::object et al. behave more like their Python counterparts.
      b4b22924
    • Wenzel Jakob's avatar
      object_api: support the number protocol · 06710020
      Wenzel Jakob authored
      This commit revamps the object_api class so that it maps most C++
      operators to their Python analogs. This makes it possible to, e.g.
      perform arithmetic using a py::int_ or py::array.
      06710020
    • Krzysztof Fornalczyk's avatar
      check for already existing enum value added; added test (#1453) · 5c8746ff
      Krzysztof Fornalczyk authored
      * check for already existing enum value added; added test
      
      * added enum value name to exception message
      
      * test for defining enum with multiple identical names moved to test_enum.cpp/py
      5c8746ff
    • Wenzel Jakob's avatar
      44e39e0d
  13. 29 Aug, 2018 2 commits
  14. 28 Aug, 2018 2 commits
  15. 19 Jul, 2018 1 commit
    • Jason Rhinelander's avatar
      Fix compatibility with catch v2 · f7bc18f5
      Jason Rhinelander authored
      Catch v2 changed the `run(...)` signature to take a `char *argv[]`,
      arguing partly that technically a `char *argv[]` type is the correct
      `main()` signature rather than `const char *argv[]`.
      
      Dropping the `const` here doesn't appear to cause any problems with
      catch v1 (tested against both the cmake-downloaded 1.9.3 and Debian's
      1.12.1 package) so we can follow suit.
      f7bc18f5
  16. 17 Jul, 2018 1 commit
    • Wenzel Jakob's avatar
      stl.h: propagate return value policies to type-specific casters (#1455) · cbd16a82
      Wenzel Jakob authored
      * stl.h: propagate return value policies to type-specific casters
      
      Return value policies for containers like those handled in in 'stl.h'
      are currently broken.
      
      The problem is that detail::return_value_policy_override<C>::policy()
      always returns 'move' when given a non-pointer/reference type, e.g.
      'std::vector<...>'.
      
      This is sensible behavior for custom types that are exposed via
      'py::class_<>', but it does not make sense for types that are handled by
      other type casters (STL containers, Eigen matrices, etc.).
      
      This commit changes the behavior so that
      detail::return_value_policy_override only becomes active when the type
      caster derives from type_caster_generic.
      
      Furthermore, the override logic is called recursively in STL type
      casters to enable key/value-specific behavior.
      cbd16a82
  17. 24 Jun, 2018 1 commit
  18. 18 May, 2018 1 commit
  19. 06 May, 2018 2 commits
  20. 14 Apr, 2018 1 commit
    • oremanj's avatar
      Add basic support for tag-based static polymorphism (#1326) · fd9bc8f5
      oremanj authored
      * Add basic support for tag-based static polymorphism
      
      Sometimes it is possible to look at a C++ object and know what its dynamic type is,
      even if it doesn't use C++ polymorphism, because instances of the object and its
      subclasses conform to some other mechanism for being self-describing; for example,
      perhaps there's an enumerated "tag" or "kind" member in the base class that's always
      set to an indication of the correct type. This might be done for performance reasons,
      or to permit most-derived types to be trivially copyable. One of the most widely-known
      examples is in LLVM: https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html
      
      This PR permits pybind11 to be informed of such conventions via a new specializable
      detail::polymorphic_type_hook<> template, which generalizes the previous logic for
      determining the runtime type of an object based on C++ RTTI. Implementors provide
      a way to map from a base class object to a const std::type_info* for the dynamic
      type; pybind11 then uses this to ensure that casting a Base* to Python creates a
      Python object that knows it's wrapping the appropriate sort of Derived.
      
      There are a number of restrictions with this tag-based static polymorphism support
      compared to pybind11's existing support for built-in C++ polymorphism:
      
      - there is no support for this-pointer adjustment, so only single inheritance is permitted
      - there is no way to make C++ code call new Python-provided subclasses
      - when binding C++ classes that redefine a method in a subclass, the .def() must be
        repeated in the binding for Python to know about the update
      
      But these are not much of an issue in practice in many cases, the impact on the
      complexity of pybind11's innards is minimal and localized, and the support for
      automatic downcasting improves usability a great deal.
      fd9bc8f5
  21. 07 Apr, 2018 1 commit
    • Boris Staletic's avatar
      Implement an enum_ property "name" · 289e5d9c
      Boris Staletic authored
      The property returns the enum_ value as a string.
      For example:
      
      >>> import module
      >>> module.enum.VALUE
      enum.VALUE
      >>> str(module.enum.VALUE)
      'enum.VALUE'
      >>> module.enum.VALUE.name
      'VALUE'
      
      This is actually the equivalent of Boost.Python "name" property.
      289e5d9c
  22. 10 Mar, 2018 1 commit
    • Jason Rhinelander's avatar
      Improve macro type handling for types with commas · e88656ab
      Jason Rhinelander authored
      - PYBIND11_MAKE_OPAQUE now takes ... rather than a single argument and
        expands it with __VA_ARGS__; this lets templated, comma-containing
        types get through correctly.
      - Adds a new macro PYBIND11_TYPE() that lets you pass the type into a
        macro as a single argument, such as:
      
            PYBIND11_OVERLOAD(PYBIND11_TYPE(R<1,2>), PYBIND11_TYPE(C<3,4>), func)
      
        Unfortunately this only works for one macro call: to forward the
        argument on to the next macro call (without the processor breaking it
        up again) requires also adding the PYBIND11_TYPE(...) to type macro
        arguments in the PYBIND11_OVERLOAD_... macro chain.
      - updated the documentation with these two changes, and use them at a couple
        places in the test suite to test that they work.
      e88656ab
  23. 28 Feb, 2018 1 commit
    • luz.paz's avatar
      Typo · 13c08072
      luz.paz authored
      13c08072
  24. 18 Feb, 2018 1 commit
  25. 12 Jan, 2018 1 commit
    • Jason Rhinelander's avatar
      Use stricter brace initialization · adbc8111
      Jason Rhinelander authored
      This updates the `py::init` constructors to only use brace
      initialization for aggregate initiailization if there is no constructor
      with the given arguments.
      
      This, in particular, fixes the regression in #1247 where the presence of
      a `std::initializer_list<T>` constructor started being invoked for
      constructor invocations in 2.2 even when there was a specific
      constructor of the desired type.
      
      The added test case demonstrates: without this change, it fails to
      compile because the `.def(py::init<std::vector<int>>())` constructor
      tries to invoke the `T(std::initializer_list<std::vector<int>>)`
      constructor rather than the `T(std::vector<int>)` constructor.
      
      By only using `new T{...}`-style construction when a `T(...)`
      constructor doesn't exist, we should bypass this by while still allowing
      `py::init<...>` to be used for aggregate type initialization (since such
      types, by definition, don't have a user-declared constructor).
      adbc8111
  26. 11 Jan, 2018 3 commits
    • Jason Rhinelander's avatar
      Fix segfault when reloading interpreter with external modules (#1092) · 326deef2
      Jason Rhinelander authored
      * Fix segfault when reloading interpreter with external modules
      
      When embedding the interpreter and loading external modules in that
      embedded interpreter, the external module correctly shares its
      internals_ptr with the one in the embedded interpreter.  When the
      interpreter is shut down, however, only the `internals_ptr` local to
      the embedded code is actually reset to nullptr: the external module
      remains set.
      
      The result is that loading an external pybind11 module, letting the
      interpreter go through a finalize/initialize, then attempting to use
      something in the external module fails because this external module is
      still trying to use the old (destroyed) internals.  This causes
      undefined behaviour (typically a segfault).
      
      This commit fixes it by adding a level of indirection in the internals
      path, converting the local internals variable to `internals **` instead
      of `internals *`.  With this change, we can detect a stale internals
      pointer and reload the internals pointer (either from a capsule or by
      creating a new internals instance).
      
      (No issue number: this was reported on gitter by @henryiii and @aoloe).
      326deef2
    • Jeff VanOss's avatar
      fix return from std::map bindings to __delitem__ (#1229) · 05d379a9
      Jeff VanOss authored
      Fix return from `std::map` bindings to `__delitem__`: we should be returning `void`, not an iterator.
      
      Also adds a test for map item deletion.
      05d379a9
    • luz.paz's avatar
      misc. typos · 28cb6764
      luz.paz authored
      Found via `codespell`
      28cb6764