|
2 | 2 |
|
3 | 3 |
|
4 | 4 | /* |
5 | | - __version__ 82163. |
| 5 | + __version__ . |
6 | 6 |
|
7 | 7 | This module must be committed separately after each AST grammar change; |
8 | 8 | The __version__ number is set to the revision number of the commit |
@@ -600,8 +600,25 @@ static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena) |
600 | 600 | return 0; |
601 | 601 | } |
602 | 602 |
|
603 | | -#define obj2ast_identifier obj2ast_object |
604 | | -#define obj2ast_string obj2ast_object |
| 603 | +static int obj2ast_stringlike(PyObject* obj, PyObject** out, PyArena* arena, |
| 604 | + const char *name) |
| 605 | +{ |
| 606 | + if (!PyUnicode_CheckExact(name)) { |
| 607 | + PyErr_Format(PyExc_TypeError, "AST %s must be of type str", name); |
| 608 | + return 1; |
| 609 | + } |
| 610 | + return obj2ast_object(obj, out, arena); |
| 611 | +} |
| 612 | + |
| 613 | +static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena) |
| 614 | +{ |
| 615 | + return obj2ast_stringlike(obj, out, arena, "identifier"); |
| 616 | +} |
| 617 | + |
| 618 | +static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena) |
| 619 | +{ |
| 620 | + return obj2ast_stringlike(obj, out, arena, "string"); |
| 621 | +} |
605 | 622 |
|
606 | 623 | static int obj2ast_int(PyObject* obj, int* out, PyArena* arena) |
607 | 624 | { |
@@ -6739,7 +6756,7 @@ PyInit__ast(void) |
6739 | 6756 | NULL; |
6740 | 6757 | if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) |
6741 | 6758 | return NULL; |
6742 | | - if (PyModule_AddStringConstant(m, "__version__", "82163") < 0) |
| 6759 | + if (PyModule_AddStringConstant(m, "__version__", "") < 0) |
6743 | 6760 | return NULL; |
6744 | 6761 | if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return |
6745 | 6762 | NULL; |
|
0 commit comments