Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
Use self.token.py() instead of acquire_gil
Browse files Browse the repository at this point in the history
As recommended in PyO3/pyo3#213 (comment)
  • Loading branch information
joar committed Nov 14, 2018
1 parent 711c3ea commit e297a4e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ impl PyIterProtocol for CSVReader {
match self.iter.next() {
Some(res) => match res {
Ok(r) => {
let gil = Python::acquire_gil();
let py = gil.python();
let py = self.token.py();
let rec: record::Record = r.into();
let t = rec.into_tuple(py);
Ok(Some(t.into_object(py)))
Expand Down
3 changes: 1 addition & 2 deletions src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ impl CSVWriter {

/// Writes a CSV row to the file.
fn writerow(&mut self, record: &PyObjectRef) -> PyResult<()> {
let gil = Python::acquire_gil();
let py = gil.python();
let py = self.token.py();
if !py.is_instance::<PyTuple, PyObjectRef>(record)? {
return Err(exc::TypeError::py_err(format!(
"Expected tuple, got {:?}",
Expand Down

0 comments on commit e297a4e

Please sign in to comment.