Summary
pygame.Surface.__init__ currently ignores the masks argument when the caller does not provide depth. This can silently accept invalid values, including None and sequences with an invalid number of mask values.
Required change
Update Surface.__init__ argument validation so it raises TypeError when a caller provides masks without also providing depth.
Rationale
The masks argument is meaningful only with an explicit pixel depth. Silently ignoring it hides caller errors and makes the runtime behavior disagree with the intended API contract.
Affected area
- Surface constructor implementation and its argument parsing
- Tests for
pygame.Surface(...) argument validation
Acceptance criteria
pygame.Surface(size, masks=value) raises TypeError when depth is omitted.
pygame.Surface(size, depth=depth, masks=None) raises TypeError.
- Valid calls that provide both
depth and four integer masks continue to work.
- Tests cover the invalid and valid call forms.
References
Summary
pygame.Surface.__init__currently ignores themasksargument when the caller does not providedepth. This can silently accept invalid values, includingNoneand sequences with an invalid number of mask values.Required change
Update
Surface.__init__argument validation so it raisesTypeErrorwhen a caller providesmaskswithout also providingdepth.Rationale
The
masksargument is meaningful only with an explicit pixel depth. Silently ignoring it hides caller errors and makes the runtime behavior disagree with the intended API contract.Affected area
pygame.Surface(...)argument validationAcceptance criteria
pygame.Surface(size, masks=value)raisesTypeErrorwhendepthis omitted.pygame.Surface(size, depth=depth, masks=None)raisesTypeError.depthand four integer masks continue to work.References