mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Add _fields attribute to ast
This commit is contained in:
1 parent
38b169e863
commit
b35330b63a
2 files changed
+8
-4
No files matched your search
Vendored
-2
@@ -275,8 +275,6 @@ class AST_Tests(unittest.TestCase):
|
||||
self._assertTrueorder(value, parent_pos)
|
||||
self.assertEqual(ast_node._fields, ast_node.__match_args__)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_AST_objects(self):
|
||||
x = ast.AST()
|
||||
self.assertEqual(x._fields, ())
|
||||
|
||||
@@ -24,8 +24,9 @@ use rustpython_parser::parser;
|
||||
#[pymodule]
|
||||
mod _ast {
|
||||
use crate::{
|
||||
builtins::PyStrRef, function::FuncArgs, AsObject, PyObjectRef, PyPayload, PyResult,
|
||||
VirtualMachine,
|
||||
builtins::{PyStrRef, PyTupleRef},
|
||||
function::FuncArgs,
|
||||
AsObject, Context, PyObjectRef, PyPayload, PyResult, VirtualMachine,
|
||||
};
|
||||
#[pyattr]
|
||||
#[pyclass(module = "_ast", name = "AST")]
|
||||
@@ -65,6 +66,11 @@ mod _ast {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pyattr(name = "_fields")]
|
||||
fn fields(ctx: &Context) -> PyTupleRef {
|
||||
ctx.empty_tuple.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[pyattr(name = "PyCF_ONLY_AST")]
|
||||
|
||||
Reference in new issue
Block a user