@@ -65,7 +65,8 @@ impl PyDict {
65
65
/// Returns an error on invalid input. In the case of key collisions,
66
66
/// this keeps the last entry seen.
67
67
#[ cfg( not( PyPy ) ) ]
68
- pub fn from_sequence ( py : Python < ' _ > , seq : PyObject ) -> PyResult < & PyDict > {
68
+ pub fn from_sequence ( seq : & PyAny ) -> PyResult < & PyDict > {
69
+ let py = seq. py ( ) ;
69
70
let dict = Self :: new ( py) ;
70
71
err:: error_on_minusone ( py, unsafe {
71
72
ffi:: PyDict_MergeFromSeq2 ( dict. into_ptr ( ) , seq. into_ptr ( ) , 1 )
@@ -505,7 +506,7 @@ mod tests {
505
506
fn test_from_sequence ( ) {
506
507
Python :: with_gil ( |py| {
507
508
let items = PyList :: new ( py, & vec ! [ ( "a" , 1 ) , ( "b" , 2 ) ] ) ;
508
- let dict = PyDict :: from_sequence ( py , items. to_object ( py ) ) . unwrap ( ) ;
509
+ let dict = PyDict :: from_sequence ( items) . unwrap ( ) ;
509
510
assert_eq ! (
510
511
1 ,
511
512
dict. get_item( "a" )
@@ -534,7 +535,7 @@ mod tests {
534
535
fn test_from_sequence_err ( ) {
535
536
Python :: with_gil ( |py| {
536
537
let items = PyList :: new ( py, & vec ! [ "a" , "b" ] ) ;
537
- assert ! ( PyDict :: from_sequence( py , items. to_object ( py ) ) . is_err( ) ) ;
538
+ assert ! ( PyDict :: from_sequence( items) . is_err( ) ) ;
538
539
} ) ;
539
540
}
540
541
0 commit comments