1
+ use crate :: call:: PyCallArgs ;
1
2
use crate :: conversion:: IntoPyObject ;
2
3
use crate :: err:: { self , PyErr , PyResult } ;
3
4
use crate :: impl_:: pycell:: PyClassObject ;
4
5
use crate :: internal_tricks:: ptr_from_ref;
5
6
use crate :: pycell:: { PyBorrowError , PyBorrowMutError } ;
6
7
use crate :: pyclass:: boolean_struct:: { False , True } ;
7
8
use crate :: types:: { any:: PyAnyMethods , string:: PyStringMethods , typeobject:: PyTypeMethods } ;
8
- use crate :: types:: { DerefToPyAny , PyDict , PyString , PyTuple } ;
9
+ use crate :: types:: { DerefToPyAny , PyDict , PyString } ;
9
10
use crate :: {
10
11
ffi, DowncastError , FromPyObject , PyAny , PyClass , PyClassInitializer , PyRef , PyRefMut ,
11
12
PyTypeInfo , Python ,
@@ -1490,30 +1491,19 @@ impl<T> Py<T> {
1490
1491
kwargs : Option < & Bound < ' py , PyDict > > ,
1491
1492
) -> PyResult < PyObject >
1492
1493
where
1493
- A : IntoPyObject < ' py , Target = PyTuple > ,
1494
+ A : PyCallArgs < ' py > ,
1494
1495
{
1495
- self . bind ( py)
1496
- . as_any ( )
1497
- . call (
1498
- // FIXME(icxolu): remove explicit args conversion
1499
- args. into_pyobject ( py) . map_err ( Into :: into) ?. into_bound ( ) ,
1500
- kwargs,
1501
- )
1502
- . map ( Bound :: unbind)
1496
+ self . bind ( py) . as_any ( ) . call ( args, kwargs) . map ( Bound :: unbind)
1503
1497
}
1504
1498
1505
1499
/// Calls the object with only positional arguments.
1506
1500
///
1507
1501
/// This is equivalent to the Python expression `self(*args)`.
1508
- pub fn call1 < ' py , N > ( & self , py : Python < ' py > , args : N ) -> PyResult < PyObject >
1502
+ pub fn call1 < ' py , A > ( & self , py : Python < ' py > , args : A ) -> PyResult < PyObject >
1509
1503
where
1510
- N : IntoPyObject < ' py , Target = PyTuple > ,
1504
+ A : PyCallArgs < ' py > ,
1511
1505
{
1512
- self . bind ( py)
1513
- . as_any ( )
1514
- // FIXME(icxolu): remove explicit args conversion
1515
- . call1 ( args. into_pyobject ( py) . map_err ( Into :: into) ?. into_bound ( ) )
1516
- . map ( Bound :: unbind)
1506
+ self . bind ( py) . as_any ( ) . call1 ( args) . map ( Bound :: unbind)
1517
1507
}
1518
1508
1519
1509
/// Calls the object without arguments.
@@ -1538,16 +1528,11 @@ impl<T> Py<T> {
1538
1528
) -> PyResult < PyObject >
1539
1529
where
1540
1530
N : IntoPyObject < ' py , Target = PyString > ,
1541
- A : IntoPyObject < ' py , Target = PyTuple > ,
1531
+ A : PyCallArgs < ' py > ,
1542
1532
{
1543
1533
self . bind ( py)
1544
1534
. as_any ( )
1545
- . call_method (
1546
- name,
1547
- // FIXME(icxolu): remove explicit args conversion
1548
- args. into_pyobject ( py) . map_err ( Into :: into) ?. into_bound ( ) ,
1549
- kwargs,
1550
- )
1535
+ . call_method ( name, args, kwargs)
1551
1536
. map ( Bound :: unbind)
1552
1537
}
1553
1538
@@ -1560,15 +1545,11 @@ impl<T> Py<T> {
1560
1545
pub fn call_method1 < ' py , N , A > ( & self , py : Python < ' py > , name : N , args : A ) -> PyResult < PyObject >
1561
1546
where
1562
1547
N : IntoPyObject < ' py , Target = PyString > ,
1563
- A : IntoPyObject < ' py , Target = PyTuple > ,
1548
+ A : PyCallArgs < ' py > ,
1564
1549
{
1565
1550
self . bind ( py)
1566
1551
. as_any ( )
1567
- . call_method1 (
1568
- name,
1569
- // FIXME(icxolu): remove explicit args conversion
1570
- args. into_pyobject ( py) . map_err ( Into :: into) ?. into_bound ( ) ,
1571
- )
1552
+ . call_method1 ( name, args)
1572
1553
. map ( Bound :: unbind)
1573
1554
}
1574
1555
0 commit comments