-
Notifications
You must be signed in to change notification settings - Fork 760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make PyTuple constructors return &PyTuple #447
Conversation
I assume the test calls Lines 96 to 98 in 874d8a0
|
Tried to make this equivalent to before using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments to clear up why the test fails. I'm not sure what this test is trying to assert so I can't say if everything is ok.
@@ -110,7 +111,7 @@ fn create_pointers_in_drop() { | |||
{ | |||
let gil = Python::acquire_gil(); | |||
let py = gil.python(); | |||
let empty = PyTuple::empty(py); | |||
let empty: Py<PyTuple> = FromPy::from_py(PyTuple::empty(py), py); | |||
ptr = empty.as_ptr(); | |||
cnt = empty.get_refcnt() - 1; | |||
let inst = Py::new(py, ClassWithDrop {}).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After calling drop(inst)
the refcount of empty is increased by 4. Only 2 of those references survive the end of the scope.
tests/test_gc.rs
Outdated
@@ -110,7 +111,7 @@ fn create_pointers_in_drop() { | |||
{ | |||
let gil = Python::acquire_gil(); | |||
let py = gil.python(); | |||
let empty = PyTuple::empty(py); | |||
let empty: Py<PyTuple> = FromPy::from_py(PyTuple::empty(py), py); | |||
ptr = empty.as_ptr(); | |||
cnt = empty.get_refcnt() - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PyTuple::empty(py)
increases the refcount of the empty tuple by 1 and FromPy::from_py(PyTuple::empty(py), py)
by 2. So if Py<PyTuple>
is used here for empty
(not necessary) then cnt
has to be corrected with
cnt = empty.get_refcnt() - 2;
3f044df
to
30778a2
Compare
Codecov Report
@@ Coverage Diff @@
## master #447 +/- ##
======================================
Coverage 87.8% 87.8%
======================================
Files 65 65
Lines 3435 3435
======================================
Hits 3016 3016
Misses 419 419
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #447 +/- ##
==========================================
- Coverage 87.8% 87.44% -0.36%
==========================================
Files 65 65
Lines 3435 3410 -25
==========================================
- Hits 3016 2982 -34
- Misses 419 428 +9
Continue to review full report at Codecov.
|
I fixed the tests and examples. |
This has a test failure in test_gc:
Also I'm not sure about the
FromPy
impl...