Skip to content

Conversation

dotysan
Copy link
Contributor

@dotysan dotysan commented Sep 17, 2025

I was wrongly attempting to copy a data stream using add_stream_from_template() and got a segfault instead of a useful response. This patch/test resolves.

The segfault occurs on assigning None.codec or None.name to codec_obj: Codec.

@dotysan
Copy link
Contributor Author

dotysan commented Sep 17, 2025

OK, clearly I'm going about this wrong.

mypy av tests
tests/test_streams.py:160: error: Value of type variable "_StreamT" of "add_stream_from_template" of "OutputContainer" cannot be "DataStream"  [type-var]
Found 1 error in 1 file (checked 88 source files)
make: *** [Makefile:34: lint] Error 1

Why doesn't this in output.pyi prevent the segfault in the first place?!?

class OutputContainer(Container):
    ...
    def add_stream_from_template(
        self, template: _StreamT, opaque: bool | None = None, **kwargs
    ) -> _StreamT: ...

@WyattBlue
Copy link
Member

.pyi files are just type stubs. They help mypy but don't affect behavior

@dotysan
Copy link
Contributor Author

dotysan commented Sep 18, 2025

Is there something I can do to get that Windoze smoke test to pass?

@WyattBlue
Copy link
Member

Windows failing seems unrelated. If you can fix this, make a separate PR

@WyattBlue WyattBlue merged commit 45eaeba into PyAV-Org:main Oct 2, 2025
5 of 6 checks passed
@dotysan dotysan deleted the data_template_segfault branch October 2, 2025 21:08
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.

2 participants