1. Sep 11, 2018
  2. Apr 29, 2018
  3. Feb 07, 2018
    • Wenzel Jakob's avatar
      mark release date in changelog · f117a48e
      Wenzel Jakob authored
      f117a48e
    • Jason Rhinelander's avatar
      Updated version/changelog for 2.2.2 · 19e90dc3
      Jason Rhinelander authored
      19e90dc3
    • Wenzel Jakob's avatar
      ebe16361
    • Jason Rhinelander's avatar
      MSVC workaround for broken `using detail::_` warning · f99f6851
      Jason Rhinelander authored
      Current MSVC generates totally bizarre errors:
      
          error C2884: 'pybind11::detail::_': introduced by using-declaration
          conflicts with local function 'pybind11::detail::_'
      
      which makes no sense (since the supposed "conflict" is the function
      itself).  Work around it by `using namespace detail;` instead (which
      also lets us drop a bunch of other `detail::` qualifications, so isn't
      actually a bad thing).
      f99f6851
    • Jason Rhinelander's avatar
      Use stricter brace initialization · c3d81d23
      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).
      c3d81d23
    • Jason Rhinelander's avatar
      Don't add duplicate patients · 56c1edb4
      Jason Rhinelander authored
      This fixes #1251 (patient vector grows without bounds) for the 2.2.2
      branch by checking that the vector doesn't already have the given
      patient.
      
      This is a little less elegant than the same fix for `master` (which
      changes the patients `vector` to an `unordered_set`), but that requires
      an internals layout change, which this approach avoids.
      56c1edb4
    • Jason Rhinelander's avatar
      Fix segfault when reloading interpreter with external modules (#1092) · 20d6d1d4
      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).
      20d6d1d4
    • Jeff VanOss's avatar
      fix return from std::map bindings to __delitem__ (#1229) · 17ad517d
      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.
      17ad517d
    • luz.paz's avatar
      misc. typos · ed0a72eb
      luz.paz authored
      Found via `codespell`
      ed0a72eb
    • Jason Rhinelander's avatar
      Use a named rather than anon struct in instance · c8f07b5d
      Jason Rhinelander authored
      The anonymous struct nested in a union triggers a -Wnested-anon-type
      warning ("anonymous types declared in an anonymous union are an
      extension") under clang (#1204).  This names the struct and defines it
      out of the definition of `instance` to get around to warning (and makes
      the code slightly simpler).
      c8f07b5d
    • Jason Rhinelander's avatar
      Fixes for numpy 1.14.0 compatibility · 7f170fe4
      Jason Rhinelander authored
      - UPDATEIFCOPY is deprecated, replaced with similar (but not identical)
        WRITEBACKIFCOPY; trying to access the flag causes a deprecation
        warning under numpy 1.14, so just check the new flag there.
      - Numpy `repr` formatting of floats changed in 1.14.0 to `[1., 2., 3.]`
        instead of the pre-1.14 `[ 1.,  2.,  3.]`.  Updated the tests to
        check for equality with the `repr(...)` value rather than the
        hard-coded (and now version-dependent) string representation.
      7f170fe4
    • Jason Rhinelander's avatar
      Added py::args ref counting tests · 8310aa46
      Jason Rhinelander authored
      8310aa46
    • Jason Rhinelander's avatar
      Simplify arg copying · 0c7aec48
      Jason Rhinelander authored
      0c7aec48
    • Zach DeVito's avatar
      Fix leak in var arg handling · 155cc7c4
      Zach DeVito authored
      When using the mixed position + vararg path, pybind over inc_ref's
      the vararg positions. Printing the ref_count() of `item` before
      and after this change you see:
      
      Before change:
      
      ```
      refcount of item before assign 3
      refcount of item after assign 5
      ```
      
      After change
      ```
      refcount of item before assign 3
      refcount of item after assign 4
      ```
      155cc7c4
    • Jason Rhinelander's avatar
      Fix premature destruction of args/kwargs arguments · c715c70e
      Jason Rhinelander authored
      The `py::args` or `py::kwargs` arguments aren't properly referenced
      when added to the function_call arguments list: their reference counts
      drop to zero if the first (non-converting) function call fails, which
      means they might be cleaned up before the second pass call runs.
      
      This commit adds a couple of extra `object`s to the `function_call`
      where we can stash a reference to them when needed to tie their
      lifetime to the function_call object's lifetime.
      
      (Credit to YannickJadoul for catching and proposing a fix in #1223).
      c715c70e