konstin
27520cb683
Fix #313
...
Thanks to @sumeet for the patch
2018-12-28 20:41:03 +01:00
konstin
322594128c
Merge pull request #316 from kngwyu/arraylist-fix
...
Fix memory leak in ArrayList
2018-12-28 20:31:26 +01:00
kngwyu
bbfe79fa57
Fix memory leak in ArrayList
2018-12-26 20:18:02 +09:00
kngwyu
419884c6ba
Use Box::into_raw instead of forget vec
2018-12-26 17:49:08 +09:00
ijl
984751a57f
Macro Rust doc
2018-12-21 02:07:43 +00:00
ijl
3452d6544a
ffi3 list macros, matching ffi2
2018-12-20 23:32:35 +00:00
Pavel Potoček
cbe668a0f4
Add (probably) forgotten type parameters to the `pyobject_native_type_convert` macro.
...
This is needed for `rust-numpy` to compile.
2018-12-05 10:56:39 +01:00
ijl
b8a6d67e31
PyTryFrom::try_from_mut_unchecked()
2018-12-01 10:27:48 -05:00
ijl
d18ebea1c2
PyTryFrom::try_from_unchecked()
...
This allows casting a PyObjectRef to a specific type of PyObject
with no overhead.
2018-12-01 10:12:27 -05:00
konstin
790a103753
Merge pull request #291 from PyO3/exception_macros
...
Refactor the exception macros
2018-12-01 13:04:06 +01:00
kngwyu
7a83c1dc0f
Revert removing default from impl FromPyObject for &T and &mut T
2018-11-29 22:45:36 +09:00
konstin
9102f2e364
Refactor the exception macros
...
* Renamed `py_exception` to `create_exception`
* The split up of the macros makes it possible to create exception structs with bodies to mimic python exceptions' members
* Used `Once` to fix a (theoretical) race condition with the is_null check
2018-11-27 23:07:15 +01:00
kngwyu
b8f1373bec
Remove default for impl PyTryFrom for &T and &mut T
2018-11-27 14:42:09 +09:00
kngwyu
2539acc1e8
Remove default from ReturnTypeIntoPyResult
2018-11-27 14:31:00 +09:00
kngwyu
119e0abde2
Fix ArrayList::truncate
2018-11-21 16:28:26 +09:00
kngwyu
949097874f
Fix bug in ArrayList::pop_back
2018-11-21 16:00:26 +09:00
kngwyu
63ec65d5ac
Refactor ReleasePool
2018-11-21 16:00:26 +09:00
kngwyu
acbab2b3f0
Use ArrayList::truncate for borrowed pointers
2018-11-21 16:00:26 +09:00
kngwyu
4c38b21e49
Fix ArrayList::push_back
2018-11-21 16:00:26 +09:00
kngwyu
be77846979
Use LinkedList<[T; 256]> in ReleasePool
2018-11-21 16:00:26 +09:00
kngwyu
25a5b74ba6
Use linked list in ReleasePool
2018-11-21 16:00:26 +09:00
konstin
13d4d66fdb
cargo fmt
2018-11-15 21:58:22 +01:00
konstin
d618ca401a
Merge pull request #274 from kngwyu/releasepool-nonnull
...
Use NonNull in ReleasePool and add bench_dict
2018-11-15 20:27:06 +01:00
konstin
f645720fe5
Merge pull request #270 from PyO3/module
...
Treat modules as normal objects
2018-11-15 20:26:46 +01:00
konstin
9c8c5a6063
Rename #[pymodinit] to #[pymodule]
2018-11-15 19:43:29 +01:00
konstin
863ffb161f
Add wrap_module macro
2018-11-15 19:43:29 +01:00
konstin
42f84ff881
Add clippy to travis
2018-11-15 15:23:45 +01:00
konstin
3de622cdfd
Better explaination for the cast
2018-11-15 12:10:16 +01:00
konstin
287a168b18
Fix test failure
2018-11-15 12:08:22 +01:00
kngwyu
a73bd06c1f
Replace NonNull::new_unchecked with new().unwrap() in test
2018-11-15 13:40:35 +09:00
konstin
5f175a41cf
Make clippy happy
2018-11-14 16:49:48 +01:00
kngwyu
6d442e5969
Use NonNull in release pool
2018-11-14 15:39:07 +09:00
Yuji Kanagawa
42dbaeb913
Merge pull request #268 from kngwyu/fix-dict-iter
...
Fix PyDictIterator's segfault(for #159 )
2018-11-13 14:29:42 +09:00
kngwyu
1081ba9447
Fix import module name in test_dict_iter
2018-11-13 11:50:13 +09:00
konstin
3614f38154
Remove some transmute
2018-11-12 21:38:20 +01:00
kngwyu
faa5efc5a1
Remove unnecessary Drop for PyDictIterator
2018-11-13 01:00:15 +09:00
kngwyu
3b01b8f6ba
Review fixes
2018-11-13 00:53:06 +09:00
konstin
d1de3338d1
Refactor PyObjectAlloc
2018-11-12 16:45:57 +01:00
kngwyu
34099b33f8
Fix PyDictIterator's segfault(for #159 )
2018-11-13 00:25:54 +09:00
konstin
6cec1c39cc
Update changelog
2018-11-12 15:11:03 +01:00
konstin
aed0466915
s/PyObjectWithToken/PyObjectWithGIL/g
2018-11-12 15:10:53 +01:00
konstin
57afb51604
Remove PyToken completely; Fixes #94
2018-11-12 14:42:21 +01:00
konstin
fb2349b6ec
Remove PyToken usages from tests
2018-11-12 14:41:29 +01:00
konstin
d2ba436d6d
Remove the unnecessary type parameter PyObjectAlloc
2018-11-12 14:37:06 +01:00
konstin
9f45efebaf
Format
2018-11-11 12:25:53 +01:00
konstin
4c0ddbe61e
Merge pull request #263 from kngwyu/fix-240
...
Fix #240
2018-11-11 11:49:31 +01:00
kngwyu
bd6f923f43
Fix #240
2018-11-09 13:11:47 +09:00
ijl
50c6129607
NonNull pointer for Py, PyObject
2018-11-08 15:09:52 +00:00
konstin
52dfc0013c
Add doc example to PyIterator
2018-11-02 22:59:30 +01:00
konstin
9ffb2c617d
Run rustfmt
2018-11-02 22:59:30 +01:00
konstin
569db5fb02
Add test with generator to PyIterator
2018-11-02 22:59:30 +01:00
konstin
264f642f19
Better doc comment for PyObject
2018-10-31 11:58:19 +01:00
konstin
8b27f1e412
Get ready for rust 2018
2018-10-31 11:43:21 +01:00
konstin
dbaa2de061
Small improvements around function calling
2018-10-31 11:38:45 +01:00
kngwyu
625a3f6738
Added a test that call call_method with kwargs
2018-10-31 15:23:18 +09:00
kngwyu
607c23d287
kwargs: Option<PyDict> -> Option<&PyDict>
2018-10-31 15:07:28 +09:00
kngwyu
56b82c2f7d
Temporary hack to compile with latest nightly
2018-10-28 18:16:44 +09:00
konstin
38651a1827
Add tox config for pyo3 itself
2018-10-09 18:49:54 +02:00
konstin
4da9110489
Add tox config for word-count
2018-10-09 18:21:52 +02:00
kngwyu
9ab63f2289
Fix build with --features="num-complex"
2018-10-04 15:47:28 +09:00
konstin
5100676497
Splitted PyTypeCreate of PyTypeObject to remove specialization
2018-10-03 22:12:22 +02:00
konstin
71c584a110
De-specialize ToBorrowedObject
2018-10-03 21:04:49 +02:00
ijl
d0f79fb9fd
PyObjectProtocol::get_type_ptr()
2018-10-03 13:10:41 +00:00
ijl
38c6d942b7
Document UTF-8 FFI assumptions
2018-09-28 22:01:04 +00:00
ijl
851d2207c0
Simplify PyString, PyBytes, PyUnicode
...
PyStringData comments mention wanting to receive interpreter-
specific unicode types. I tried implementing this, but it's
more complex and slower to call libpython to fill a buffer
of u32 or such and convert that in Rust using widestring.
This implementation receives UTF-8 from PyUnicode_AsUTF8AndSize()
in python3 and PyUnicode_AsUTF8String() in python2. PyStringData
is removed as unnecessary.
The data() method on PyString, PyBytes, and PyUnicode is
replaced with as_bytes().
The python2 API changes improve the performance of
extracting unicode strings.
2018-09-28 21:47:44 +00:00
konstin
3a95d163ca
New rustfmt version
...
You might need to upgrade to the latest nightly to get the same results
2018-09-28 23:34:57 +02:00
konstin
8930bd00e0
Fix PyUnicode alias
2018-09-28 23:03:24 +02:00
konstin
0b1906b626
Merge branch 'master' into datetime-fix
2018-09-28 22:47:04 +02:00
kngwyu
f12e299f1c
Remove PyDateTime_*Types
2018-09-28 23:56:57 +09:00
Paul Ganssle
b869f09808
Add documentation to types/datetime.rs
...
This adds some light doc comments to the safe rust bindings.
2018-09-27 09:22:31 -04:00
Paul Ganssle
a528c1e877
Add documentation to the datetime ffi bindings
2018-09-27 09:20:11 -04:00
konstin
ed2739829f
Fix the other part from #231
2018-09-27 01:44:17 +02:00
konstin
78a5053b22
Fix #231
2018-09-27 01:11:31 +02:00
konstin
05874d3f1a
Fix tests
2018-09-27 01:11:31 +02:00
ijl
28bc3cf1e6
PyDict::from_sequence()
2018-09-25 14:19:23 +00:00
ijl
868e28d5ad
Fix segfault on calling unknown method
2018-09-24 02:49:52 +00:00
ijl
6a961298af
PyUnicode_AsUTF8AndSize, PyUnicode_AsUTF8 *const c_char API change
...
Noted in https://docs.python.org/3/c-api/unicode.html
2018-09-21 21:54:51 +00:00
konstin
302c099a76
Big refactoring to shrink the prelude
2018-09-21 23:34:28 +02:00
kngwyu
247da8d341
Implement pow, abs, neg for PyComplex
2018-09-21 14:48:43 +09:00
kngwyu
6b362a4654
Implement convsersion between num_complex::Complex and PyComplex
2018-09-21 14:23:01 +09:00
kngwyu
7ea875fc49
Implement Add/Sub/Mul/Div for &PyComplex
2018-09-21 12:48:42 +09:00
kngwyu
c6d588877b
Intoroduce PyComplex with minimum APIs
2018-09-20 11:52:57 +09:00
konstin
2904291b9e
Better code generation
2018-09-17 19:48:22 +02:00
konstin
10ef6cd111
Fix cfg on PyEval_InitThread to fix #219
2018-09-11 22:38:31 +02:00
konstin
d92e522243
Syn 0.15
2018-09-09 00:20:04 +02:00
konstin
ddc6313e74
`#[pyclass]` objects can now be returned from rust functions
2018-09-06 18:04:13 +02:00
konstin
e6569ae61e
Remove ::pyo3::argparse::get_kwargs for from_borrowed_ptr_or_opt
2018-09-03 20:50:02 +02:00
konstin
29c882577c
Get rid of another default fn
2018-09-03 01:02:39 +02:00
konstin
f58549f1d8
Get rid of a bunch of PyTokens
2018-09-02 23:33:45 +02:00
konstin
0101dc8136
Two default fn less
2018-08-31 21:11:08 +02:00
konstin
aa8be251d3
Fix python 2
2018-08-29 22:47:02 +02:00
konstin
8de0574aad
Clippy stuff
2018-08-26 21:35:53 +02:00
konstin
7293cdbc6f
Remove dead impl
2018-08-26 19:14:55 +02:00
konstin
3b8adeb484
Rewrite sq_ass_item generation to avoid specialization
2018-08-26 19:09:34 +02:00
konstin
4847d56325
Less java-esque naming
2018-08-26 18:48:57 +02:00
konstin
6d9ee7fc38
Rewrite the set attr / del attr function to avoid specialization
2018-08-26 18:40:50 +02:00
konstin
7c0379b13a
Remove many specialization uses
...
From over a hundret "default fn" uses down to 17
2018-08-25 20:48:17 +02:00
konstin
33e72a2b03
Merge pull request #209 from joar/fix/escape-square-brackets
...
Escape square brackets when they're not references
2018-08-24 19:55:11 +02:00
Joar Wandborg
47bbe8cc1e
Use backticks instead of single quotes
...
The backticks properly monospace the Python expressions in the rendered
docs, and also escape square brackets inside so that rustdoc isn't
trying to parse them as references.
2018-08-24 19:15:48 +02:00
Joar Wandborg
b5e5bcf223
Escape square brackets in references.
2018-08-24 19:01:14 +02:00
konstin
3e7d5280ca
Merge pull request #200 from pganssle/datetime
...
Initial datetime bindings
2018-08-22 18:00:05 +02:00
Paul Ganssle
6202e2641b
Fix race condition in test_seq_set_item_refcnt
...
This test previously relied on a stable reference count for None, which
is not likely to be true in multi-threaded code. This creates an object
specifically for the test to avoid race conditions.
2018-08-21 20:32:12 -04:00
Paul Ganssle
c3986a7244
Fix race condition in test_borrowed*
...
This fixes a race condition in test_borrowed and test_borrowed_nested
by making the object under test different in each thread.
2018-08-21 20:20:24 -04:00
Paul Ganssle
c7a967c340
Silence type complexity warnings in ffi
2018-08-21 18:33:33 -04:00
Paul Ganssle
a09ffad32a
Add convnience function to unwrap Option<&PyObject>
2018-08-21 18:33:33 -04:00
konstin
7053c897aa
Get rid of #[inline(always)] and replace it with #[inline]
...
I've just seen that this had been hidden from clippy through the ffi module reordering, but fixing this on master would cause merge conflicts, so I'm fixing this here directly
2018-08-21 18:33:33 -04:00
Paul Ganssle
a05a78f7e0
Use smallest types for Py{Date}{Time} constructors
...
Because it's unlikely that anything other than the `year` parameter will
change in the C Python API, the rest can be restricted to their logical
ranges, which improves the compile-time error checking.
2018-08-21 18:33:33 -04:00
Paul Ganssle
5d5689f95b
Switch Py{Date}{Time} constructor parameters to i32
...
While the valid ranges for the constructor parameters is the same when
expressed as either u32 or i32, since the Python API uses i32 in their
public interface, we won't have to make any changes to the signatures if
the Python behavior changes (e.g. supporting negative years) without
their API changing.
2018-08-21 18:33:33 -04:00
Paul Ganssle
b66ab7fabc
Move cache population logic into PyDateTime_IMPORT
...
This more closely mimics the CPython API, since the import logic
populates the global, it should also populate the cache.
This also allows users to eagerly initialize the Python C API if
preferred (for example, doing so before populating a bunch of threads,
or before making performance measurements that will be thrown off by a
lazy import).
2018-08-21 18:33:32 -04:00
Paul Ganssle
26c5397618
Implement Debug for PyObject in Python 2
...
For whatever reason I cannot build rustapi_module without this, and
rather than figure out the core problem, I figured that, for symmetry,
it makes sense to just implement Debug for PyObject.
2018-08-21 18:33:32 -04:00
Paul Ganssle
cf3b1d2cc3
Remove leading __ from private cache objects
...
These were basically cargo culted from lazy_static's implementation, but
they are not idiomatic or necessary to indicate that these are private
variables.
2018-08-21 18:33:32 -04:00
Paul Ganssle
a271ba9ed9
Use unified implementation for ffi::datetime
...
In the future we can make ffi::object, ffi::pycapsule, etc as
crate-public, but importing the specific symbols is a light touch way to
do this.
2018-08-21 18:33:32 -04:00
Paul Ganssle
3357fabb35
Remove 'Component' from ComponentAccess Traits
2018-08-21 18:33:32 -04:00
Paul Ganssle
f68d0932f4
Unwrap PyDateTime_CAPI function fields
...
Because the PyDateTime_CAPI is always accessed via a lazy-initialized
static reference, it is not necessary to handle the case where the
functions on the C struct have not been initialized.
2018-08-21 18:33:32 -04:00
Paul Ganssle
bcc27bd522
Change datetime constructors to use Rust Option
...
This makes it cleaner to call PyTime::new and PyDateTime::new from Rust
without needing to retrieve a Python None.
2018-08-21 18:33:32 -04:00
Paul Ganssle
bcc42315ff
Inline parameter typecasts
...
Clippy complains about the one-letter variables, but it's preferable to
do the typecasts in-line anyway.
2018-08-21 18:33:31 -04:00
Paul Ganssle
94bd0d7b6d
Relax constraints on PyDateTimeAPI initialization
...
As noted in the comments, using call_once to initialize the
PyDateTimeAPI singleton is causing deadlocks with the GIL; these
deadlocks can be avoided by falling back on CPython's own locking
behavior.
2018-08-21 18:33:28 -04:00
konstin
771d59b913
Fix another bunch of clippy lints
2018-08-21 23:51:13 +02:00
Paul Ganssle
12c20a75d9
Move datetime interface to exclusively use functions
2018-08-21 14:29:36 -04:00
Paul Ganssle
ee658de1fb
Run rustfmt after datetime changes
...
Most of the datetime related changes were made before pyo3 switched to
using rustfmt, so I ran rustfmt only on the final commit to make it
easier to rewrite history as necessary (for fixups and whatnot).
2018-08-21 14:29:36 -04:00
Paul Ganssle
996c2baec8
Add preliminary Python 2 support to datetime bindings
...
The bounds checking tests are xfail because the datetime "fast path"
constructor didn't do bounds checking until bpo-29100 was resolved in
CPython commit b67f0967386a9c90411, which was merged for Python 3.6.
This functionality should be simple to backport to earlier versions in a
future commit.
BPO issue:
https://bugs.python.org/issue29100
CPython commit:
b67f096738
2018-08-21 14:29:36 -04:00
Paul Ganssle
cd6f7295a1
Add type checking FFI bindings
2018-08-21 14:29:36 -04:00
Paul Ganssle
f701bccbdf
Add PyTime component accessors
2018-08-21 14:29:36 -04:00
Paul Ganssle
ecf3aaafb2
Add PyDateTime component accessors
2018-08-21 14:29:35 -04:00
Paul Ganssle
0b39452276
Add accessors to PyDateTime_Date
2018-08-21 14:29:35 -04:00
Paul Ganssle
08e7e0f55a
Add PyDelta component accessors
...
Adds the PyDateTime_DELTA_GET_{comp} accessors and bindings to them in
the PyDelta object.
2018-08-21 14:29:35 -04:00
Paul Ganssle
f47697e2b5
Refactor pyobject_* macros
...
See 8c26020015
for general change.
2018-08-21 14:29:35 -04:00
Paul Ganssle
f5e0785654
Add time_with_fold
2018-08-21 14:29:35 -04:00
Paul Ganssle
c49bbe4549
Add PyDateTime::from_timestamp
2018-08-21 14:29:34 -04:00
Paul Ganssle
7256bc85b7
Add PyDate::from_timestamp
2018-08-21 14:29:34 -04:00
Paul Ganssle
e8d6a4bcc0
Version qualify PyDateTimeAPI
2018-08-21 14:29:34 -04:00
Paul Ganssle
8d781cb03f
Add datetime.timedelta
2018-08-21 14:29:34 -04:00
Paul Ganssle
f45362943d
Add datetime.time
2018-08-21 14:29:34 -04:00
Paul Ganssle
d7b90c1b3a
Add datetime.datetime and switch to PyResult<Py<T>>
2018-08-21 14:29:34 -04:00
Paul Ganssle
496b879525
Add objects/datetime.rs
2018-08-21 14:29:33 -04:00
Paul Ganssle
2b74cdbd57
Add initial bindings for datetime.h
2018-08-21 14:29:31 -04:00
konstin
82129c70b4
Added an explenation that the GIL can temporarily be released even while holding a GILGuard
2018-08-20 22:56:24 +02:00
konstin
db4a2d9017
Get rid of the pyobject_extract macro
2018-08-20 22:53:43 +02:00
konstin
991a8b94d2
More nightly fixes
2018-08-19 20:42:17 +02:00
konstin
b12b65cfae
Cleanup
2018-08-19 20:06:47 +02:00
kngwyu
ff2871f325
Remove unnecessary feature gates from doc tests
2018-08-14 18:29:15 +09:00
konstin
d0ed68414a
Many small improvements
2018-08-04 19:56:59 +02:00
konstin
fe8a719ee1
Rustfmt all the things ✔️
2018-07-30 23:05:10 +02:00
konstin
83db765889
Refactoring
2018-07-30 22:56:25 +02:00
konstin
d9d1650fc4
Fix #197 - Remove tuple to dict conversions
2018-07-30 22:52:36 +02:00
konstin
27633da3b1
Merge pull request #191 from milesgranger/master
...
Python::run should return PyObjectRef result
2018-07-30 17:49:57 +02:00
Miles Granger
a13b79459f
Return PyObjectRef result from Python::run
2018-07-29 22:00:36 +02:00
kngwyu
5e1ce01251
Enable generics parameter in pyobject_native_type!
2018-07-28 14:46:00 +09:00
konstin
2627fa8a08
0.3.2
2018-07-22 21:36:18 +02:00
konstin
ff70f45071
(Hopefully) get travis to build the guide for tags
2018-07-18 23:28:14 +02:00