Repository navigation
Allow common builtins such as sum and super by default - #40
Merged
Merged
Conversation
eliotwrobson
added a commit
that referenced
this pull request
Nov 11, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Correct solutions that use sum, any, all, super and similar builtins failed with a NameError unless the question whitelisted them. These builtins don't give student code anything that plain Python syntax doesn't. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eliotwrobson
force-pushed
the
claude/more-default-builtins
branch
from
November 11, 2026 06:05
dc3e280 to
4ed4214
Compare
eliotwrobson
marked this pull request as ready for review
November 11, 2026 06:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Student code only gets RestrictedPython's list of safe builtins, which leaves out many that correct solutions use. A solution like
sum(values) / len(values)fails withNameError: name 'sum' is not definedunless the question setsbuiltin_whitelist, and so does any class that callssuper().This adds
all,any,ascii,bin,bytearray,classmethod,Ellipsis,filter,format,frozenset,iter,next,NotImplemented,object,property,reversed,staticmethod,sum,superandtypeto the defaults. None of them gives student code anything it can't already do with plain syntax. Builtins that read or change namespaces and attributes by name (getattr,setattr,vars,globalsand the like), plusopen,eval,exec,compileandinput, stay blocked.The new
test_default_builtinsscenario fails without this change.test_helper_modules_workspaceusedsumas its example of a blocked builtin, so it usesvarsnow.The docs in #38 describe the current defaults, and I'll update them to match this PR.
🤖 Generated with Claude Code