1. Oct 25, 2016
    • 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
    • Wenzel Jakob's avatar
      Merge pull request #453 from aldanor/feature/numpy-scalars · dd9bd777
      Wenzel Jakob authored
      NumPy scalars to ctypes conversion support
      dd9bd777
    • Ivan Smirnov's avatar
      Use detail::get_type_info() wherever sensible · 8f3e045d
      Ivan Smirnov authored
      This reduces direct access to internals.registered_types_cpp to
      just a few places.
      8f3e045d
    • Wenzel Jakob's avatar
      6ba98650
  2. Oct 23, 2016
  3. Oct 22, 2016
  4. Oct 21, 2016
    • Ben North's avatar
      Test uncopyable static member · bbe45082
      Ben North authored
      Without the previous commit, this test generates a core dump.
      bbe45082
    • Ben North's avatar
      Fix wrapper's 'value' and 'owned' if ctor missing · 24a2054d
      Ben North authored
      type_caster_generic::cast(): The values of
      
          wrapper->value
          wrapper->owned
      
      are incorrect in the case that a return value policy of 'copy' is
      requested but there is no copy-constructor.  (Similarly 'move'.)  In
      particular, if the source object is a static instance, the destructor of
      the 'object' 'inst' leads to class_::dealloc() which incorrectly
      attempts to 'delete' the static instance.
      
      This commit re-arranges the code to be clearer as to what the values of
      'value' and 'owned' should be in the various cases.  Behaviour is
      different to previous code only in two situations:
      
      policy = copy but no copy-ctor: Old code leaves 'value = src, owned =
      true', which leads to trouble.  New code leaves 'value = nullptr, owned
      = false', which is correct.
      
      policy = move but no move- or copy-ctor: old code leaves 'value = src,
      owned = true', which leads to trouble.  New code leaves 'value =
      nullptr, owned = false', which is correct.
      24a2054d
    • Wenzel Jakob's avatar
      Merge pull request #454 from dean0x7d/shared_ptr · 77898af0
      Wenzel Jakob authored
      Support std::shared_ptr holder type out of the box
      77898af0
  5. Oct 20, 2016
  6. Oct 17, 2016
    • Wenzel Jakob's avatar
      Merge pull request #450 from dean0x7d/explicit-bool · 35995856
      Wenzel Jakob authored
      Make operator bool() explicit
      35995856
    • 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
    • Wenzel Jakob's avatar
      Merge pull request #449 from jagerman/no-implicit-conversions · 135fd149
      Wenzel Jakob authored
      Disable most implicit conversion constructors
      135fd149
    • 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
  7. Oct 16, 2016
  8. Oct 15, 2016
  9. Oct 14, 2016