Skip to content

Remove raise of StopIteration in ttvdb4 generator - #1472

Merged
rcrdnalor merged 1 commit into
MythTV:masterfrom
SteveErl:erlMerge44
Sep 21, 2026
Merged

rcrdnalor merged 1 commit into
MythTV:masterfrom
SteveErl:erlMerge44

Conversation

@SteveErl

@SteveErl SteveErl commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Tom Peterson's suggested change to replace the "raise StopIteration" lines with "return" inside the generator routine has been implemented in ttvdbv4_api.py. This is the PEP 479-compliant way to end a generator.

In myth4ttvdbv4.py, the buildSingle() routine has been updated to accommodate a possible StopIteration exception when the generator is called. If that exception happens, we will exit with a "No matching episode found" error message. Similarly, buildCollection() has been updated to exit with a "No matching collection found" error message when the provided reference identifier does not correspond to a known TV series.

The tvmaze metadata grabber had similar vague failures.

For a non-existent episode:

tvmaze.py -l en -a US -D 32938 2 35
ERROR: <class 'AttributeError'> : 'NoneType' object has no attribute 'name'

For a non-existent series:

tvmaze.py -l en -a US -C 99999
ERROR: <class 'AttributeError'> : 'NoneType' object has no attribute 'name'

The tvmaze.py script has been updated to switch these to:

tvmaze.py -l en -a US -D 32938 2 35
ERROR: <class 'SystemExit'> : No matching episode found

tvmaze.py -l en -a US -C 99999
ERROR: <class 'SystemExit'> : No matching collection found

This provides consistent behavior between ttvdb4.py and tvmaze.py grabbers for these types of failures.

Resolves #1433

Checklist

Tom Peterson's suggested change to replace the
"raise StopIteration" lines with "return" inside the
generator routine has been implemented in ttvdbv4_api.py.
This is the PEP 479-compliant way to end a generator.

In myth4ttvdbv4.py, the buildSingle() routine has
been updated to accommodate a possible StopIteration
exception when the generator is called. If that
exception happens, we will exit with a "No matching
episode found" error message. Similarly, buildCollection()
has been updated to exit with a "No matching collection
found" error message when the provided reference
identifier does not correspond to a known TV series.

The tvmaze metadata grabber had similar vague failures.

For a non-existent episode:
tvmaze.py -l en -a US -D 32938 2 35
ERROR: <class 'AttributeError'> : 'NoneType' object has no attribute 'name'

For a non-existent series:
tvmaze.py -l en -a US -C 99999
ERROR: <class 'AttributeError'> : 'NoneType' object has no attribute 'name'

The tvmaze.py script has been updated to switch these to:

tvmaze.py -l en -a US -D 32938 2 35
ERROR: <class 'SystemExit'> : No matching episode found

tvmaze.py -l en -a US -C 99999
ERROR: <class 'SystemExit'> : No matching collection found

This provides consistent behavior between ttvdb4.py and
tvmaze.py grabbers for these types of failures.

Resolves MythTV#1433
@SteveErl

SteveErl commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@rcrdnalor Could you please review #1465
#1466, and #1472? Thanks.

@rcrdnalor
rcrdnalor merged commit 7972fc8 into MythTV:master Sep 21, 2026
11 checks passed
@SteveErl
SteveErl deleted the erlMerge44 branch September 21, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ttvdb4.py -D crashes with RuntimeError: generator raised StopIteration when episode generator is exhausted

2 participants