Skip to content

Commit 1aa005b

Browse files
itamarometa-codesync[bot]
authored andcommitted
Make test_shot_view_ref_count refcount check work on Python 3.14
Summary: On Python 3.14, `sys.getrefcount` on a local variable returns one less than on 3.12 (the interpreter borrows local references for the call), so the absolute `== 2` check fails. Comparing against a plain local keeps the "nothing else holds the reconstruction" check on both versions. ___ Differential Revision: D122956965 fbshipit-source-id: 399b777013c49a93a8fd5735779a70e4b06eac71
1 parent c4985ce commit 1aa005b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎opensfm/test/test_types.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,12 @@ def test_shot_view_ref_count() -> None:
267267
rec.create_shot("shot1", "camera1", pygeometry.Pose())
268268
rec.create_shot("shot2", "camera1", pygeometry.Pose())
269269

270-
# The reconstruction has ref count = 2
270+
# Only the local variable references the reconstruction. Compare against
271+
# another local: Python 3.14 borrows local references when calling
272+
# getrefcount, so the absolute value differs between versions.
273+
local_only = object()
271274
count = sys.getrefcount(rec)
272-
assert count == 2
275+
assert count == sys.getrefcount(local_only)
273276

274277
# The map has a bigger ref count because all the views are referencing it
275278
count = sys.getrefcount(rec.map)

0 commit comments

Comments
 (0)