Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ee99d3

Browse files
committed
Make pgen compile with pydebug. Duplicate normalized names, as it may
be longer than the old string.
1 parent cd280fb commit 1ee99d3

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Parser/tokenizer.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ tok_new(void)
128128
tok->read_coding_spec = 0;
129129
tok->issued_encoding_warning = 0;
130130
tok->encoding = NULL;
131+
#ifndef PGEN
131132
tok->decoding_readline = NULL;
132133
tok->decoding_buffer = NULL;
134+
#endif
133135
return tok;
134136
}
135137

@@ -225,8 +227,8 @@ get_coding_spec(const char *s, int size)
225227
char* r = new_string(begin, t - begin);
226228
char* q = get_normal_name(r);
227229
if (r != q) {
228-
assert(strlen(r) >= strlen(q));
229-
strcpy(r, q);
230+
PyMem_DEL(r);
231+
r = new_string(q, strlen(q));
230232
}
231233
return r;
232234
}
@@ -584,8 +586,10 @@ PyTokenizer_Free(struct tok_state *tok)
584586
{
585587
if (tok->encoding != NULL)
586588
PyMem_DEL(tok->encoding);
589+
#ifndef PGEN
587590
Py_XDECREF(tok->decoding_readline);
588591
Py_XDECREF(tok->decoding_buffer);
592+
#endif
589593
if (tok->fp != NULL && tok->buf != NULL)
590594
PyMem_DEL(tok->buf);
591595
PyMem_DEL(tok);

Parser/tokenizer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ struct tok_state {
4545
int read_coding_spec; /* whether 'coding:...' has been read */
4646
int issued_encoding_warning; /* whether non-ASCII warning was issued */
4747
char *encoding;
48+
#ifndef PGEN
4849
PyObject *decoding_readline; /* codecs.open(...).readline */
4950
PyObject *decoding_buffer;
51+
#endif
5052
const char* enc;
5153
const char* str;
5254
};

0 commit comments

Comments
 (0)