-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test which used to fail (crash)
- Loading branch information
1 parent
fff7439
commit 9310354
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from neuron import h | ||
import sys | ||
|
||
|
||
def test_seg_from_sec_x_ref(): | ||
"""A reproducer of calling `seg_from_sec_x` without a Python Section | ||
Without the fix generally we would get (upon interpreter exit) | ||
Fatal Python error: bool_dealloc: "deallocating True or False: bug likely caused by a refcount error in a C extension" | ||
""" | ||
## Pure python (ok) | ||
# soma1 = nrn.Section("soma1") | ||
# nc1 = h.NetCon(soma1(0.5)._ref_v, None) | ||
# seg1 = nc1.preseg() | ||
# print(sys.getrefcount(seg1)) | ||
# print(sys.getrefcount(seg1.sec)) | ||
|
||
h("create soma") | ||
h("objref nc") | ||
h("objref nil") | ||
h('soma nc = new NetCon(&v(0.5), nil)') | ||
nc = h.nc | ||
seg = nc.preseg() # uses `seg_from_sec_x` | ||
|
||
assert sys.getrefcount(seg) == 2 | ||
assert sys.getrefcount(seg.sec) == 3 |