Skip to content

Commit b35330b

Browse files
committed
Add _fields attribute to ast
1 parent 38b169e commit b35330b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Lib/test/test_ast.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,6 @@ def _assertTrueorder(self, ast_node, parent_pos):
275275
self._assertTrueorder(value, parent_pos)
276276
self.assertEqual(ast_node._fields, ast_node.__match_args__)
277277

278-
# TODO: RUSTPYTHON
279-
@unittest.expectedFailure
280278
def test_AST_objects(self):
281279
x = ast.AST()
282280
self.assertEqual(x._fields, ())

vm/src/stdlib/ast.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ use rustpython_parser::parser;
2424
#[pymodule]
2525
mod _ast {
2626
use crate::{
27-
builtins::PyStrRef, function::FuncArgs, AsObject, PyObjectRef, PyPayload, PyResult,
28-
VirtualMachine,
27+
builtins::{PyStrRef, PyTupleRef},
28+
function::FuncArgs,
29+
AsObject, Context, PyObjectRef, PyPayload, PyResult, VirtualMachine,
2930
};
3031
#[pyattr]
3132
#[pyclass(module = "_ast", name = "AST")]
@@ -65,6 +66,11 @@ mod _ast {
6566
}
6667
Ok(())
6768
}
69+
70+
#[pyattr(name = "_fields")]
71+
fn fields(ctx: &Context) -> PyTupleRef {
72+
ctx.empty_tuple.clone()
73+
}
6874
}
6975

7076
#[pyattr(name = "PyCF_ONLY_AST")]

0 commit comments

Comments
 (0)