From f74a5946816c4cb0176d5a90b1774c63abb93a35 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Fri, 19 Aug 2016 12:00:13 +0300 Subject: Issue #12946: Remove dead code in PyModule_GetDict PyModule_NewObject already sets md_dict to PyDict_New(): m->md_dict = PyDict_New(); --- Objects/moduleobject.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Objects/moduleobject.c') diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index a4cdc206c1..fb568f531d 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -444,8 +444,7 @@ PyModule_GetDict(PyObject *m) return NULL; } d = ((PyModuleObject *)m) -> md_dict; - if (d == NULL) - ((PyModuleObject *)m) -> md_dict = d = PyDict_New(); + assert(d != NULL); return d; } -- cgit v1.2.1 From 7f1175b2722f3d84bf7dc0b6198353487e050384 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 26 Sep 2016 23:14:44 +0300 Subject: Issue #27914: Fixed a comment in PyModule_ExcDef. Patch by Xiang Zhang. --- Objects/moduleobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Objects/moduleobject.c') diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index d88b06aea4..dcae1c4da5 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -380,7 +380,7 @@ PyModule_ExecDef(PyObject *module, PyModuleDef *def) for (cur_slot = def->m_slots; cur_slot && cur_slot->slot; cur_slot++) { switch (cur_slot->slot) { case Py_mod_create: - /* handled in PyModule_CreateFromSlots */ + /* handled in PyModule_FromDefAndSpec2 */ break; case Py_mod_exec: ret = ((int (*)(PyObject *))cur_slot->value)(module); -- cgit v1.2.1 From 57c0f2e61c8a5893c37e576a3a03ba5e57c1132c Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 20 Nov 2016 09:13:07 +0200 Subject: Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize. --- Objects/moduleobject.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Objects/moduleobject.c') diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index b6a2d6fe9c..79be51a806 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -483,7 +483,7 @@ PyModule_GetName(PyObject *m) if (name == NULL) return NULL; Py_DECREF(name); /* module dict has still a reference */ - return _PyUnicode_AsString(name); + return PyUnicode_AsUTF8(name); } PyObject* @@ -516,7 +516,7 @@ PyModule_GetFilename(PyObject *m) fileobj = PyModule_GetFilenameObject(m); if (fileobj == NULL) return NULL; - utf8 = _PyUnicode_AsString(fileobj); + utf8 = PyUnicode_AsUTF8(fileobj); Py_DECREF(fileobj); /* module dict has still a reference */ return utf8; } @@ -569,7 +569,7 @@ _PyModule_ClearDict(PyObject *d) if (PyUnicode_READ_CHAR(key, 0) == '_' && PyUnicode_READ_CHAR(key, 1) != '_') { if (Py_VerboseFlag > 1) { - const char *s = _PyUnicode_AsString(key); + const char *s = PyUnicode_AsUTF8(key); if (s != NULL) PySys_WriteStderr("# clear[1] %s\n", s); else @@ -589,7 +589,7 @@ _PyModule_ClearDict(PyObject *d) !_PyUnicode_EqualToASCIIString(key, "__builtins__")) { if (Py_VerboseFlag > 1) { - const char *s = _PyUnicode_AsString(key); + const char *s = PyUnicode_AsUTF8(key); if (s != NULL) PySys_WriteStderr("# clear[2] %s\n", s); else -- cgit v1.2.1