mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Format the Python-tokenize module and fix exit path (GH-27935)
This commit is contained in:
parent
33d95c6fac
commit
214c2e5d91
1 changed files with 46 additions and 47 deletions
|
@ -8,8 +8,7 @@ typedef struct {
|
|||
} tokenize_state;
|
||||
|
||||
static tokenize_state *
|
||||
get_tokenize_state(PyObject* module)
|
||||
{
|
||||
get_tokenize_state(PyObject *module) {
|
||||
return (tokenize_state *)PyModule_GetState(module);
|
||||
}
|
||||
|
||||
|
@ -24,9 +23,9 @@ class _tokenizer.tokenizeriter "tokenizeriterobject *" "_tokenize_get_state_by_t
|
|||
[clinic start generated code]*/
|
||||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=96d98ee2fef7a8bc]*/
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
struct tok_state* tok;
|
||||
typedef struct
|
||||
{
|
||||
PyObject_HEAD struct tok_state *tok;
|
||||
} tokenizeriterobject;
|
||||
|
||||
/*[clinic input]
|
||||
|
@ -50,6 +49,7 @@ tokenizeriter_new_impl(PyTypeObject *type, const char *source)
|
|||
}
|
||||
self->tok = PyTokenizer_FromUTF8(source, 1);
|
||||
if (self->tok == NULL) {
|
||||
Py_DECREF(filename);
|
||||
return NULL;
|
||||
}
|
||||
self->tok->filename = filename;
|
||||
|
@ -72,7 +72,8 @@ tokenizeriter_next(tokenizeriterobject* it)
|
|||
PyObject *str = NULL;
|
||||
if (start == NULL || end == NULL) {
|
||||
str = PyUnicode_FromString("");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
str = PyUnicode_FromStringAndSize(start, end - start);
|
||||
}
|
||||
if (str == NULL) {
|
||||
|
@ -125,7 +126,6 @@ static PyType_Spec tokenizeriter_spec = {
|
|||
.slots = tokenizeriter_slots,
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
tokenizemodule_exec(PyObject *m)
|
||||
{
|
||||
|
@ -134,8 +134,7 @@ tokenizemodule_exec(PyObject* m)
|
|||
return -1;
|
||||
}
|
||||
|
||||
state->TokenizerIter = (PyTypeObject *)PyType_FromModuleAndSpec(
|
||||
m, &tokenizeriter_spec, NULL);
|
||||
state->TokenizerIter = (PyTypeObject *)PyType_FromModuleAndSpec(m, &tokenizeriter_spec, NULL);
|
||||
if (state->TokenizerIter == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue