Skip to content

Make Disposition an IntFlag so Stream.disposition setter accepts members#2257

Open
HotariTobu wants to merge 1 commit intoPyAV-Org:mainfrom
HotariTobu:fix/disposition-intflag
Open

Make Disposition an IntFlag so Stream.disposition setter accepts members#2257
HotariTobu wants to merge 1 commit intoPyAV-Org:mainfrom
HotariTobu:fix/disposition-intflag

Conversation

@HotariTobu
Copy link
Copy Markdown

Closes #2256

Stream.disposition is typed as Disposition but the runtime setter (self.ptr.disposition = value, a C int field) calls int(value), which fails on plain Flag members because they are not int subclasses. Switching Disposition to IntFlag fixes the contract: members are int subclasses, so the conversion succeeds, and bitwise / membership semantics are unchanged.

# Before: TypeError
video.disposition = Disposition.attached_pic

# After: OK
video.disposition = Disposition.attached_pic

Both av/stream.py (runtime) and av/stream.pyi (stub) are updated for consistency.

Stream.disposition is typed as Disposition but the runtime setter
assigns to a C int field, calling int(value). Plain Flag members are
not int subclasses, so this raises TypeError. IntFlag members are int
subclasses; bitwise / membership semantics are preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

Stream.disposition setter rejects Disposition enum members at runtime (type/runtime contract mismatch)

1 participant