Skip to content

Fix clip() with no arguments in Python and Scheme - #3108

Merged
nesbox merged 1 commit into
nesbox:mainfrom
r3wretrhy:fix/python-clip-no-args-3042
Oct 22, 2026
Merged

nesbox merged 1 commit into
nesbox:mainfrom
r3wretrhy:fix/python-clip-no-args-3042

Conversation

@r3wretrhy

Copy link
Copy Markdown
Contributor

Fixes #3042.

The wiki says clip() with no arguments resets the clip region to the whole screen. That works in Lua, but Python and Scheme throw an error instead.

For Python I made the four arguments default to None. When none are given it calls clip(0, 0, 240, 136), the same thing Lua does. clip(1, 2) is still an error, like in Lua.

Scheme was a different problem. scheme_clip handles the empty call fine, but api.h marks all four clip args as required and s7 rejects the call before it gets that far. I changed the required count to 0. mruby uses that field too, but mrb_clip parses its args as optional anyway, and ruby's results didn't change.

I tested with the conformance runner, built the way the CI tests job builds it. On main the clip row is red for python and scheme (clip/set and clip/reset). With this change clip is green for every language, and python and scheme each go from 19 to 17 divergences. Nothing else in the table moved. ctest passes and clang-format 20.1.6 has no complaints.

clip() with no arguments should reset the clipping region to the whole
screen, as it does in Lua and the other languages. In Python the binding
required all four arguments, and in Scheme the API table marked all four
as required, so the reset path in scheme_clip was never reached.

Fixes nesbox#3042
@nesbox
nesbox merged commit fc48f10 into nesbox:main Oct 22, 2026
17 checks passed
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.

clip() not working in pocketpy without arguments

2 participants