Skip to content

Conversation

@zzjjbb
Copy link
Contributor

@zzjjbb zzjjbb commented Jun 7, 2025

Validate self.ptr before access: uninitialized properties should return None rather than crash the Python interpreter

@zzjjbb zzjjbb closed this Jun 7, 2025
@zzjjbb zzjjbb reopened this Jun 7, 2025
@zzjjbb
Copy link
Contributor Author

zzjjbb commented Jun 7, 2025

I don't know why format, layout, and sample_rate are looked up in the same way, but AudioFifo().sample_rate will raise an AttributeError, while AudioFifo().format and AudioFifo().layout will crash the interpreter. Is there any magic caused by the docstrings in Cython?

@zzjjbb zzjjbb force-pushed the zzjjbb-patch branch 2 times, most recently from 0c8b65d to f017079 Compare June 7, 2025 03:09
@WyattBlue
Copy link
Member

I think setting sample_rate to 0 and raising AttributeErrors is better than using None. Otherwise, this type widening would be a "breaking change"

Validate self.ptr before access: uninitialized properties should return None
rather than crash the Python interpreter
@WyattBlue WyattBlue merged commit 3739f59 into PyAV-Org:main Jun 7, 2025
5 checks passed
@zzjjbb zzjjbb deleted the zzjjbb-patch branch June 8, 2025 18:59
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