mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
add a asdl bytes type, so Bytes.s be properly typechecked
This commit is contained in:
parent
18205baf25
commit
e249841903
5 changed files with 28 additions and 7 deletions
|
|
@ -776,6 +776,7 @@ static PyObject* ast2obj_object(void *o)
|
|||
}
|
||||
#define ast2obj_identifier ast2obj_object
|
||||
#define ast2obj_string ast2obj_object
|
||||
#define ast2obj_bytes ast2obj_object
|
||||
|
||||
static PyObject* ast2obj_int(long b)
|
||||
{
|
||||
|
|
@ -813,6 +814,15 @@ static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
|
|||
return obj2ast_object(obj, out, arena);
|
||||
}
|
||||
|
||||
static int obj2ast_bytes(PyObject* obj, PyObject** out, PyArena* arena)
|
||||
{
|
||||
if (!PyBytes_CheckExact(obj)) {
|
||||
PyErr_SetString(PyExc_TypeError, "AST bytes must be of type bytes");
|
||||
return 1;
|
||||
}
|
||||
return obj2ast_object(obj, out, arena);
|
||||
}
|
||||
|
||||
static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
|
||||
{
|
||||
int i;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue