Skip to content

Commit 3f36a57

Browse files
committed
Issue python#19515: Remove identifiers duplicated in the same file.
Patch written by Andrei Dorian Duma.
1 parent dcf17f8 commit 3f36a57

File tree

5 files changed

+6
-11
lines changed

5 files changed

+6
-11
lines changed

Modules/_io/bufferedio.c

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ bufferediobase_readinto(PyObject *self, PyObject *args)
5252
Py_buffer buf;
5353
Py_ssize_t len;
5454
PyObject *data;
55-
_Py_IDENTIFIER(read);
5655

5756
if (!PyArg_ParseTuple(args, "w*:readinto", &buf)) {
5857
return NULL;

Modules/_io/iobase.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ _Py_IDENTIFIER(__IOBase_closed);
6363
#define IS_CLOSED(self) \
6464
_PyObject_HasAttrId(self, &PyId___IOBase_closed)
6565

66+
_Py_IDENTIFIER(read);
67+
6668
/* Internal methods */
6769
static PyObject *
6870
iobase_unsupported(const char *message)
@@ -180,7 +182,6 @@ static PyObject *
180182
iobase_close(PyObject *self, PyObject *args)
181183
{
182184
PyObject *res;
183-
_Py_IDENTIFIER(__IOBase_closed);
184185

185186
if (IS_CLOSED(self))
186187
Py_RETURN_NONE;
@@ -454,7 +455,6 @@ iobase_readline(PyObject *self, PyObject *args)
454455
int has_peek = 0;
455456
PyObject *buffer, *result;
456457
Py_ssize_t old_size = -1;
457-
_Py_IDENTIFIER(read);
458458
_Py_IDENTIFIER(peek);
459459

460460
if (!PyArg_ParseTuple(args, "|O&:readline", &_PyIO_ConvertSsize_t, &limit)) {
@@ -848,7 +848,6 @@ rawiobase_readall(PyObject *self, PyObject *args)
848848
return NULL;
849849

850850
while (1) {
851-
_Py_IDENTIFIER(read);
852851
PyObject *data = _PyObject_CallMethodId(self, &PyId_read,
853852
"i", DEFAULT_BUFFER_SIZE);
854853
if (!data) {

Modules/cjkcodecs/multibytecodec.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ static PyObject *multibytecodec_encode(MultibyteCodec *,
5151

5252
#define MBENC_RESET MBENC_MAX<<1 /* reset after an encoding session */
5353

54+
_Py_IDENTIFIER(write);
55+
5456
static PyObject *
5557
make_tuple(PyObject *object, Py_ssize_t len)
5658
{
@@ -1569,7 +1571,6 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self,
15691571
PyObject *unistr)
15701572
{
15711573
PyObject *str, *wr;
1572-
_Py_IDENTIFIER(write);
15731574

15741575
str = encoder_encode_stateful(STATEFUL_ECTX(self), unistr, 0);
15751576
if (str == NULL)
@@ -1639,7 +1640,6 @@ mbstreamwriter_reset(MultibyteStreamWriterObject *self)
16391640
assert(PyBytes_Check(pwrt));
16401641
if (PyBytes_Size(pwrt) > 0) {
16411642
PyObject *wr;
1642-
_Py_IDENTIFIER(write);
16431643

16441644
wr = _PyObject_CallMethodId(self->stream, &PyId_write, "O", pwrt);
16451645
if (wr == NULL) {

Objects/typeobject.c

-1
Original file line numberDiff line numberDiff line change
@@ -5633,7 +5633,6 @@ slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
56335633
PyObject *func;
56345634
PyObject *newargs, *x;
56355635
Py_ssize_t i, n;
5636-
_Py_IDENTIFIER(__new__);
56375636

56385637
func = _PyObject_GetAttrId((PyObject *)type, &PyId___new__);
56395638
if (func == NULL)

Python/pythonrun.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737

3838
_Py_IDENTIFIER(builtins);
3939
_Py_IDENTIFIER(excepthook);
40+
_Py_IDENTIFIER(flush);
4041
_Py_IDENTIFIER(last_traceback);
4142
_Py_IDENTIFIER(last_type);
4243
_Py_IDENTIFIER(last_value);
44+
_Py_IDENTIFIER(name);
4345
_Py_IDENTIFIER(ps1);
4446
_Py_IDENTIFIER(ps2);
4547
_Py_IDENTIFIER(stdin);
@@ -215,7 +217,6 @@ get_codec_name(const char *encoding)
215217
{
216218
char *name_utf8, *name_str;
217219
PyObject *codec, *name = NULL;
218-
_Py_IDENTIFIER(name);
219220

220221
codec = _PyCodec_Lookup(encoding);
221222
if (!codec)
@@ -512,7 +513,6 @@ flush_std_files(void)
512513
PyObject *fout = _PySys_GetObjectId(&PyId_stdout);
513514
PyObject *ferr = _PySys_GetObjectId(&PyId_stderr);
514515
PyObject *tmp;
515-
_Py_IDENTIFIER(flush);
516516

517517
if (fout != NULL && fout != Py_None && !file_is_closed(fout)) {
518518
tmp = _PyObject_CallMethodId(fout, &PyId_flush, "");
@@ -1009,7 +1009,6 @@ create_stdio(PyObject* io,
10091009
_Py_IDENTIFIER(open);
10101010
_Py_IDENTIFIER(isatty);
10111011
_Py_IDENTIFIER(TextIOWrapper);
1012-
_Py_IDENTIFIER(name);
10131012
_Py_IDENTIFIER(mode);
10141013

10151014
/* stdin is always opened in buffered mode, first because it shouldn't
@@ -2130,7 +2129,6 @@ flush_io(void)
21302129
{
21312130
PyObject *f, *r;
21322131
PyObject *type, *value, *traceback;
2133-
_Py_IDENTIFIER(flush);
21342132

21352133
/* Save the current exception */
21362134
PyErr_Fetch(&type, &value, &traceback);

0 commit comments

Comments
 (0)