1. 25 Oct, 2016 1 commit
    • Jason Rhinelander's avatar
      Prevent overwriting previous declarations · 6873c202
      Jason Rhinelander authored
      Currently pybind11 doesn't check when you define a new object (e.g. a
      class, function, or exception) that overwrites an existing one.  If the
      thing being overwritten is a class, this leads to a segfault (because
      pybind still thinks the type is defined, even though Python no longer
      has the type).  In other cases this is harmless (e.g. replacing a
      function with an exception), but even in that case it's most likely a
      bug.
      
      This code doesn't prevent you from actively doing something harmful,
      like deliberately overwriting a previous definition, but detects
      overwriting with a run-time error if it occurs in the standard
      class/function/exception/def registration interfaces.
      
      All of the additions are in non-template code; the result is actually a
      tiny decrease in .so size compared to master without the new test code
      (977304 to 977272 bytes), and about 4K higher with the new tests.
      6873c202
  2. 24 Oct, 2016 1 commit
  3. 23 Oct, 2016 1 commit
  4. 22 Oct, 2016 5 commits
  5. 21 Oct, 2016 1 commit
  6. 20 Oct, 2016 9 commits
  7. 17 Oct, 2016 1 commit
    • Dean Moldovan's avatar
      Make operator bool() explicit · c889ebd0
      Dean Moldovan authored
      This prevents unwanted conversions to bool or int such as:
      ```
      py::object my_object;
      
      std::cout << my_object << std::endl; // compiles and prints 0 or 1
      int n = my_object; // compiles and is nonsense
      ```
      
      With `explicit operator bool()` the above cases become compiler errors.
      c889ebd0
  8. 16 Oct, 2016 1 commit
    • Jason Rhinelander's avatar
      Disable most implicit conversion constructors · 12d76600
      Jason Rhinelander authored
      We have various classes that have non-explicit constructors that accept
      a single argument, which is implicitly making them implicitly
      convertible from the argument.  In a few cases, this is desirable (e.g.
      implicit conversion of std::string to py::str, or conversion of double
      to py::float_); in many others, however, it is unintended (e.g. implicit
      conversion of size_t to some pre-declared py::array_t<T> type).
      
      This disables most of the unwanted implicit conversions by marking them
      `explicit`, and comments the ones that are deliberately left implicit.
      12d76600
  9. 14 Oct, 2016 1 commit
  10. 13 Oct, 2016 4 commits
  11. 12 Oct, 2016 2 commits
    • Wenzel Jakob's avatar
      Permit creation of NumPy arrays with a "base" object that owns the data · 369e9b39
      Wenzel Jakob authored
      This patch adds an extra base handle parameter to most ``py::array`` and
      ``py::array_t<>`` constructors. If specified along with a pointer to
      data, the base object will be registered within NumPy, which increases
      the base's reference count. This feature is useful to create shallow
      copies of C++ or Python arrays while ensuring that the owners of the
      underlying can't be garbage collected while referenced by NumPy.
      
      The commit also adds a simple test function involving a ``wrap()``
      function that creates shallow copies of various N-D arrays.
      369e9b39
    • Pim Schellart's avatar
      d2afe7f0
  12. 11 Oct, 2016 1 commit
  13. 09 Oct, 2016 1 commit
    • Wenzel Jakob's avatar
      extra python version sanity check at import time · 4c00fd9e
      Wenzel Jakob authored
      Python 3.5 can often import pybind11 modules compiled compiled for
      Python 3.4 (i.e. all symbols can be resolved), but this leads to crashes
      later on due to changes in various Python-internal data structures. This
      commit adds an extra sanity check to prevent a successful import when
      the Python versions don't match.
      4c00fd9e
  14. 08 Oct, 2016 1 commit
    • Wenzel Jakob's avatar
      unpacking_collector: allow nullptr-valued kwargs argument · e71ab8f4
      Wenzel Jakob authored
      This fixes an issue that can arise when forwarding (*args, **kwargs)
      captured from a pybind11-bound function call to another Python function.
      When the initial function call includes no keyword arguments, the
      py::kwargs field is set to nullptr and causes a crash later on.
      e71ab8f4
  15. 07 Oct, 2016 1 commit
  16. 02 Oct, 2016 1 commit
    • Jason Rhinelander's avatar
      Re-add (but deprecated) bool operator for attr/items · 7b8e3f9e
      Jason Rhinelander authored
      PR #425 removed the bool operator from attribute accessors.  This is
      likely in use by existing code as it was the only way before #425 added
      the `hasattr` function to check for the existence of an attribute, via:
      
          if (obj.attr("foo")) { ... }
      
      This commit adds it back in for attr and item accessors, but with a
      deprecation warning to use `hasattr(obj, ...)` or `obj.contains(...)`
      instead.
      7b8e3f9e
  17. 30 Sep, 2016 2 commits
  18. 29 Sep, 2016 1 commit
  19. 27 Sep, 2016 2 commits
  20. 23 Sep, 2016 3 commits