Commit Graph

311 Commits

Author SHA1 Message Date
David Hewitt 1cecad884a Release 0.12.2 2020-10-12 12:56:46 +01:00
kngwyu e7092fe630 Make PyCFunction more backward-compatible 2020-10-09 01:35:55 +09:00
kngwyu 359d878fb6 Fix clippy warnings 2020-10-09 00:28:16 +09:00
kngwyu b42886a38a Change PyCFunction to take &'static str as a function name 2020-10-08 17:26:55 +09:00
kngwyu 41c2f5a748 Use &'static CStr for representing method names and docs 2020-10-08 17:26:55 +09:00
kngwyu ddfbee4b3c Add null-check for function's documents 2020-10-08 17:26:55 +09:00
dvermd df984ec8df
Keyword only arguments (#1209)
* allow keyword arguments without default value

* allow keyword-only arguments
2020-10-01 13:34:54 +09:00
David Hewitt c05815520c Release 0.12.1 2020-09-16 21:45:36 +01:00
David Hewitt 32be8d9a3c Release 0.12 2020-09-12 14:13:45 +01:00
David Hewitt 151af7a0b7
Merge pull request #1115 from davidhewitt/std-py-err
Implement std::error::Error for PyErr
2020-09-10 21:17:11 +01:00
David Hewitt b9e95dc7c9 Implement std::error::Error for PyErr 2020-09-10 19:04:24 +01:00
Sebastian Pütz 22881a3c2f Change add_function, ensure static docstrings.
Change add_function to take `&PyCFunction` instead of a wrapper
fn and ensure that dostrings of functions are `&'static str`.
2020-09-09 12:37:37 +02:00
Sebastian Pütz be877d133f Add constructor for PyCFunction. 2020-09-08 14:26:08 +02:00
Sebastian Pütz 2e8010b5df Add native Function native types.
Add bindings for PyCFunction, PyFunction, PyClassMethod and
PyStaticMethod.
2020-09-08 09:51:31 +02:00
Sebastian Pütz e65b849ab6 Doc fixes, changelog and rename. 2020-09-05 10:20:22 +02:00
Sebastian Pütz 795c054511 Possible to pass PyModule as first arg.
This commit makes it possible to access the module of a function
by passing the `need_module` argument to the pyfn and pyfunction
macros.
2020-09-04 09:01:21 +02:00
Sebastian Pütz 3214249010 Make python function wrapper creation fallible.
Wrapping a function can fail if we can't get the module name.

Based on suggestion by @kngwyu
2020-09-03 15:48:32 +02:00
Sebastian Pütz 1f017b66fb Move py fn wrapper argument expansion to associated function.
Suggestion by @kngwyu.

Additionally replace some `expect` calls with error handling.
2020-09-03 15:21:33 +02:00
Sebastian Pütz 5bbca1a052 Set the module of `#[pyfunction]`s.
Previously neither the module nor the name of the module of
pyfunctions were registered. This commit passes the module and
its name when creating a new pyfunction.

PyModule::add_function and PyModule::add_module have been added and are
set to replace `add_wrapped` in a future release. `add_wrapped` is kept
for compatibility reasons during the transition.

Depending on whether a `PyModule` or `Python` is the argument for the
Python function-wrapper, the module will be registered with the function.
2020-09-03 14:49:28 +02:00
David Hewitt 74f981120d
Merge pull request #1146 from programmerjake/fix-snake-case-warning
Add #[allow(non_snake_case)] to function with generated name
2020-09-03 08:27:43 +01:00
Jacob Lifshay 7acf8d9f57 Add #[allow(non_snake_case)] to function with generated name
Fixes #1145
2020-09-02 20:32:51 -07:00
David Hewitt 3e86e4c247 Refactor proc_macro optional / python detection 2020-09-02 08:01:21 +01:00
David Hewitt c5065893dd
Merge pull request #1135 from sebpuetz/remove-duplicate-pool
Remove duplicate pool and py in py_init.
2020-09-01 20:47:04 +01:00
Sebastian Puetz 4e7fe6e638 Remove proc-macro panics. 2020-09-01 20:27:47 +02:00
Sebastian Puetz 74ecd15580 Remove duplicate pool and py in py_init. 2020-09-01 19:45:27 +02:00
Sebastian Pütz 0f32f886b8 More FromPyObject derive suggestions by @davidhewitt 2020-08-30 19:16:59 +02:00
Sebastian Pütz 7a9f4a1633 FromPyObject derive suggestions by @kngwyu 2020-08-30 15:33:50 +02:00
Sebastian Pütz a8c5379eff Add compile fail tests for FromPyObject derives + some fixes.
Fix some error messages and accidental passes.
2020-08-30 12:54:13 +02:00
Sebastian Pütz 7781bb78de Specify item key and attr name as arguments. 2020-08-30 10:22:01 +02:00
Sebastian Pütz 60fe4925f5 '#[derive(FromPyObject)]` changes suggested by @davidwhewitt. 2020-08-30 10:22:01 +02:00
Sebastian Pütz 7168309464 Derive FromPyObject 2020-08-30 10:22:01 +02:00
kngwyu 3e958bf607 Encapsule slot_setter's behavior to an iterator 2020-08-20 14:41:51 +09:00
kngwyu f086f48499 Left-hand operands are fellback to RH ones for type mismatching 2020-08-20 14:33:47 +09:00
Yuji Kanagawa c4d9ab227e
Merge branch 'master' into iterator-example 2020-08-10 17:11:00 +09:00
kngwyu 093dda375f Improve lifetime insertions for #[pyproto] 2020-08-10 15:18:16 +09:00
David Hewitt be239d405f Rework Py methods and documentation 2020-08-09 12:29:25 +01:00
Toru Ogawa 668e5e9d1f PyObject -> pyo3::PyObject 2020-08-04 20:27:29 +09:00
kngwyu f5f2e84f4b Enable &Self in #[pymethods] again 2020-07-28 20:55:38 +09:00
David Hewitt 0764362d17 Remove hidden PyErr::restore_and_minus1 and PyErr::restore_and_null 2020-07-19 22:39:41 +01:00
David Hewitt c6aa7a8a47 Fix clippy warning of useless conversion 2020-07-17 19:06:56 +01:00
kngwyu 6cbe9ff30d Bump version to 0.11.1 2020-06-30 14:53:55 +09:00
kngwyu d76fe7835a Introduce #[pyclass(unsendable)] 2020-06-30 12:30:17 +09:00
kngwyu 42f592be4c Fix clippy warning 2020-06-28 14:11:11 +09:00
kngwyu fd94a0d55c Bump version to 0.11.0 2020-06-27 23:59:44 +09:00
David Hewitt c3e993e5a6 Apply suggestions from code review
Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2020-06-27 14:56:15 +01:00
David Hewitt e140b729fc Allow #[getter] and #[setter] functions to take PyRef 2020-06-27 14:55:22 +01:00
David Hewitt a9c7e12be0 Allow skipping the return type completely for `#[pyproto]` methods returning `()`. 2020-06-23 11:51:02 +01:00
David Hewitt 0c59b05e1f
Merge pull request #996 from davidhewitt/pyproto-simplifications
Refactor `#[pyproto]` Result types
2020-06-23 11:49:39 +01:00
David Hewitt c7a4b4770f Refactor `#[pyproto]` Result types 2020-06-23 11:08:36 +01:00
Yuji Kanagawa f757c99dac
Merge pull request #994 from scalexm/ptr
`LazyStaticType::get_or_init` returns an `*mut` instead of a `&` ref
2020-06-23 10:07:43 +09:00