-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect and fail if using mismatched holders #2644
base: master
Are you sure you want to change the base?
Commits on Nov 6, 2020
-
Configuration menu - View commit details
-
Copy full SHA for b498e52 - Browse repository at this point
Copy the full SHA b498e52View commit details -
Detect and fail if using mismatched holders
This adds a check when registering a class or a function with a holder return that the same wrapped type hasn't been previously seen using a different holder type. This fixes pybind#1138 by detecting the failure; currently attempting to use two different holder types (e.g. a unique_ptr<T> and shared_ptr<T>) in difference places can segfault because we don't have any type safety on the holder instances.
Configuration menu - View commit details
-
Copy full SHA for 44f23a2 - Browse repository at this point
Copy the full SHA 44f23a2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0fe5697 - Browse repository at this point
Copy the full SHA 0fe5697View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6360006 - Browse repository at this point
Copy the full SHA 6360006View commit details -
Configuration menu - View commit details
-
Copy full SHA for e2aa4ec - Browse repository at this point
Copy the full SHA e2aa4ecView commit details -
fixup! Replace global map holders_seen with local holder_type in regi…
…stered type_info Having replaced the global map holders_seen, we can only check return values against already registered types. Hence, we need to replace the check at initialization time with a check at call time (when casting the return value).
Configuration menu - View commit details
-
Copy full SHA for 502bf24 - Browse repository at this point
Copy the full SHA 502bf24View commit details -
Generalize holder compatibility check for derived classes
A derived class needs to use the same holder type as its base class(es). So far, the check was constrained to the default holder vs. custom holder types. Thus, we replace the simple check (based on the default_holder flag) with a more elaborate one, comparing holder type names.
Configuration menu - View commit details
-
Copy full SHA for 7852e7d - Browse repository at this point
Copy the full SHA 7852e7dView commit details -
Configuration menu - View commit details
-
Copy full SHA for cde5c11 - Browse repository at this point
Copy the full SHA cde5c11View commit details
Commits on Nov 8, 2020
-
fixup! Replace global map holders_seen with local holder_type in regi…
…stered type_info Improve wording and variable name: - seen_holder_name -> holder_name - seen holder -> declared holder
Configuration menu - View commit details
-
Copy full SHA for d5c4386 - Browse repository at this point
Copy the full SHA d5c4386View commit details -
fixup! fixup! Replace global map holders_seen with local holder_type …
…in registered type_info Runtime costs of checking holder compatibility for function return types during can be limited to definition time (instead of calling time), if we require types to be registered before defining a function. This allows to lookup the type_info record and validate the holder type as expected. As we cannot call functions with an unregistered return type anyway, I think this is a good compromise.
Configuration menu - View commit details
-
Copy full SHA for e57a3db - Browse repository at this point
Copy the full SHA e57a3dbView commit details
Commits on Nov 9, 2020
-
fixup! fixup! fixup! Replace global map holders_seen with local holde…
…r_type in registered type_info Simplify code using type_id<Return>()
Configuration menu - View commit details
-
Copy full SHA for 8115384 - Browse repository at this point
Copy the full SHA 8115384View commit details
Commits on Nov 23, 2020
-
Move runtime check for holder compatibility into function registration
To avoid costly runtime checks at function call time, compatibility of holder types is now checked once at functionn registration time. This assumes that all custom argument types are declared in advance!
Configuration menu - View commit details
-
Copy full SHA for 02d0b53 - Browse repository at this point
Copy the full SHA 02d0b53View commit details