GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Raise ValueError for None in Expr lists to match CPython validator by changjoon-park · Pull Request #7656 · RustPython/RustPython

Raise ValueError for None in Expr lists to match CPython validator #7656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
youknowone merged 2 commits into RustPython:main from changjoon-park:fix-ast-none-disallowed
Apr 23, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Raise ValueError for None in Expr lists to match CPython validator #7656

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
1a32bfa
Raise ValueError for None in Expr lists to match CPython validator
changjoon-park Apr 22, 2026
95c6566
Drop redundant .to_owned() on new_value_error argument
changjoon-park Apr 22, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

12 changes: 0 additions & 12 deletions 12 Lib/test/test_ast/test_ast.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2132,14 +2132,12 @@ def cls(bases=None, keywords=None, body=None, decorator_list=None, type_params=N
self.stmt(cls(decorator_list=[ast.Name("x", ast.Store())]),
"must have Load context")

@unittest.expectedFailure # TODO: RUSTPYTHON; ValueError not raised
def test_delete(self):
self.stmt(ast.Delete([]), "empty targets on Delete")
self.stmt(ast.Delete([None]), "None disallowed")
self.stmt(ast.Delete([ast.Name("x", ast.Load())]),
"must have Del context")

@unittest.expectedFailure # TODO: RUSTPYTHON; ValueError not raised
def test_assign(self):
self.stmt(ast.Assign([], ast.Constant(3)), "empty targets on Assign")
self.stmt(ast.Assign([None], ast.Constant(3)), "None disallowed")
Expand Down Expand Up @@ -2271,7 +2269,6 @@ def test_expr(self):
e = ast.Expr(ast.Name("x", ast.Store()))
self.stmt(e, "must have Load context")

@unittest.skip("TODO: RUSTPYTHON; called `Option::unwrap()` on a `None` value")
def test_boolop(self):
b = ast.BoolOp(ast.And(), [])
self.expr(b, "less than 2 values")
Expand Down Expand Up @@ -2301,14 +2298,12 @@ def test_ifexp(self):
for args in (s, l, l), (l, s, l), (l, l, s):
self.expr(ast.IfExp(*args), "must have Load context")

@unittest.expectedFailure # TODO: RUSTPYTHON; ValueError not raised
def test_dict(self):
d = ast.Dict([], [ast.Name("x", ast.Load())])
self.expr(d, "same number of keys as values")
d = ast.Dict([ast.Name("x", ast.Load())], [None])
self.expr(d, "None disallowed")

@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: expected some sort of expr, but got None
def test_set(self):
self.expr(ast.Set([None]), "None disallowed")
s = ast.Set([ast.Name("x", ast.Store())])
Expand Down Expand Up @@ -2338,19 +2333,15 @@ def wrap(gens):
return fac(ast.Name("x", ast.Store()), gens)
self._check_comprehension(wrap)

@unittest.expectedFailure # TODO: RUSTPYTHON; ValueError not raised
def test_listcomp(self):
self._simple_comp(ast.ListComp)

@unittest.expectedFailure # TODO: RUSTPYTHON; ValueError not raised
def test_setcomp(self):
self._simple_comp(ast.SetComp)

@unittest.expectedFailure # TODO: RUSTPYTHON; ValueError not raised
def test_generatorexp(self):
self._simple_comp(ast.GeneratorExp)

@unittest.expectedFailure # TODO: RUSTPYTHON; ValueError not raised
def test_dictcomp(self):
g = ast.comprehension(ast.Name("y", ast.Store()),
ast.Name("p", ast.Load()), [], 0)
Expand Down Expand Up @@ -2382,7 +2373,6 @@ def test_compare(self):
comp = ast.Compare(left, [ast.In()], [ast.Constant("blah")])
self.expr(comp)

@unittest.expectedFailure # TODO: RUSTPYTHON; ValueError not raised
def test_call(self):
func = ast.Name("x", ast.Load())
args = [ast.Name("y", ast.Load())]
Expand Down Expand Up @@ -2428,11 +2418,9 @@ def _sequence(self, fac):
self.expr(fac([ast.Name("x", ast.Store())], ast.Load()),
"must have Load context")

@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: expected some sort of expr, but got None
def test_list(self):
self._sequence(ast.List)

@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: expected some sort of expr, but got None
def test_tuple(self):
self._sequence(ast.Tuple)

Expand Down
2 changes: 2 additions & 0 deletions 2 crates/vm/src/stdlib/_ast/expression.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ impl Node for ast::Expr {
let interpolation =
string::TStringInterpolation::ast_from_object(vm, source_file, object)?;
return string::interpolation_to_expr(vm, interpolation);
} else if vm.is_none(&object) {
return Err(vm.new_value_error("None disallowed in expression list"));
} else {
return Err(vm.new_type_error(format!(
"expected some sort of expr, but got {}",
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.