Skip to content

Commit f66624f

Browse files
authored
Merge pull request #656 from JonnyWong16/feature/object_parent
Fix checking object parent when the weakref is dead
2 parents c9b2c36 + caa7f10 commit f66624f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

plexapi/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ def _isChildOf(self, **kwargs):
124124
See all possible `**kwargs*` in :func:`~plexapi.base.PlexObject.fetchItem`.
125125
"""
126126
obj = self
127-
while obj._parent is not None:
127+
while obj and obj._parent is not None:
128128
obj = obj._parent()
129-
if obj._checkAttrs(obj._data, **kwargs):
129+
if obj and obj._checkAttrs(obj._data, **kwargs):
130130
return True
131131
return False
132132

tests/test_video.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,16 @@ def test_video_Episode_hidden_season(episode):
799799
show.defaultAdvanced()
800800

801801

802+
def test_video_Episode_parent_weakref(show):
803+
season = show.season(season=1)
804+
episode = season.episode(episode=1)
805+
assert episode._parent is not None
806+
assert episode._parent() == season
807+
episode = show.season(season=1).episode(episode=1)
808+
assert episode._parent is not None
809+
assert episode._parent() is None
810+
811+
802812
# Analyze seems to fail intermittently
803813
@pytest.mark.xfail
804814
def test_video_Episode_analyze(tvshows):

0 commit comments

Comments
 (0)