From ffbf24bf0cc297d080d6d68bc809a9c156c49123 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Tue, 22 Feb 2011 20:15:44 +0000 Subject: Issue #8914: fix various warnings from the Clang static analyzer v254. --- Python/sysmodule.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index de51155a49..89fe4f1fe6 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1176,7 +1176,6 @@ PySys_AddXOption(const wchar_t *s) PyObject *opts; PyObject *name = NULL, *value = NULL; const wchar_t *name_end; - int r; opts = get_xoptions(); if (opts == NULL) @@ -1194,7 +1193,7 @@ PySys_AddXOption(const wchar_t *s) } if (name == NULL || value == NULL) goto error; - r = PyDict_SetItem(opts, name, value); + PyDict_SetItem(opts, name, value); Py_DECREF(name); Py_DECREF(value); return; -- cgit v1.2.1 From 5db419fc1fe185b5ada72ff88056bc21e1d70c01 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 6 Mar 2011 10:35:42 +0100 Subject: Remove sys.subversion and svn build identification leftovers. --- Python/sysmodule.c | 94 ------------------------------------------------------ 1 file changed, 94 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 9c94ececd5..d06adc0aca 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1255,7 +1255,6 @@ int_info -- a struct sequence with information about the int implementation.\n\ maxsize -- the largest supported length of containers.\n\ maxunicode -- the largest supported character\n\ builtin_module_names -- tuple of module names built into this interpreter\n\ -subversion -- subversion information of the build as tuple\n\ version -- the version of this interpreter as a string\n\ version_info -- version information as a named tuple\n\ hexversion -- version information encoded as a single integer\n\ @@ -1303,95 +1302,6 @@ settrace() -- set the global debug tracing function\n\ ) /* end of sys_doc */ ; -/* Subversion branch and revision management */ -static const char _patchlevel_revision[] = PY_PATCHLEVEL_REVISION; -static const char headurl[] = "$HeadURL$"; -static int svn_initialized; -static char patchlevel_revision[50]; /* Just the number */ -static char branch[50]; -static char shortbranch[50]; -static const char *svn_revision; - -static void -svnversion_init(void) -{ - const char *python, *br_start, *br_end, *br_end2, *svnversion; - Py_ssize_t len; - int istag = 0; - - if (svn_initialized) - return; - - python = strstr(headurl, "/python/"); - if (!python) { - strcpy(branch, "unknown branch"); - strcpy(shortbranch, "unknown"); - } - else { - br_start = python + 8; - br_end = strchr(br_start, '/'); - assert(br_end); - - /* Works even for trunk, - as we are in trunk/Python/sysmodule.c */ - br_end2 = strchr(br_end+1, '/'); - - istag = strncmp(br_start, "tags", 4) == 0; - if (strncmp(br_start, "trunk", 5) == 0) { - strcpy(branch, "trunk"); - strcpy(shortbranch, "trunk"); - } - else if (istag || strncmp(br_start, "branches", 8) == 0) { - len = br_end2 - br_start; - strncpy(branch, br_start, len); - branch[len] = '\0'; - - len = br_end2 - (br_end + 1); - strncpy(shortbranch, br_end + 1, len); - shortbranch[len] = '\0'; - } - else { - Py_FatalError("bad HeadURL"); - return; - } - } - - - svnversion = _Py_svnversion(); - if (strcmp(svnversion, "Unversioned directory") != 0 && strcmp(svnversion, "exported") != 0) - svn_revision = svnversion; - else if (istag) { - len = strlen(_patchlevel_revision); - assert(len >= 13); - assert(len < (sizeof(patchlevel_revision) + 13)); - strncpy(patchlevel_revision, _patchlevel_revision + 11, - len - 13); - patchlevel_revision[len - 13] = '\0'; - svn_revision = patchlevel_revision; - } - else - svn_revision = ""; - - svn_initialized = 1; -} - -/* Return svnversion output if available. - Else return Revision of patchlevel.h if on branch. - Else return empty string */ -const char* -Py_SubversionRevision() -{ - svnversion_init(); - return svn_revision; -} - -const char* -Py_SubversionShortBranch() -{ - svnversion_init(); - return shortbranch; -} - PyDoc_STRVAR(flags__doc__, "sys.flags\n\ @@ -1595,10 +1505,6 @@ _PySys_Init(void) PyUnicode_FromString(Py_GetVersion())); SET_SYS_FROM_STRING("hexversion", PyLong_FromLong(PY_VERSION_HEX)); - svnversion_init(); - SET_SYS_FROM_STRING("subversion", - Py_BuildValue("(sss)", "CPython", branch, - svn_revision)); SET_SYS_FROM_STRING("_mercurial", Py_BuildValue("(szz)", "CPython", _Py_hgidentifier(), _Py_hgversion())); -- cgit v1.2.1 From b877636c2dfc63692a7649584cfc9fcf72ba2dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sat, 26 Mar 2011 01:55:15 +0100 Subject: Remove traces of division_warning left over from Python 2 (#10998) --- Python/sysmodule.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 31c6939068..33255ad72e 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1312,7 +1312,6 @@ static PyTypeObject FlagsType; static PyStructSequence_Field flags_fields[] = { {"debug", "-d"}, - {"division_warning", "-Q"}, {"inspect", "-i"}, {"interactive", "-i"}, {"optimize", "-O or -OO"}, @@ -1336,9 +1335,9 @@ static PyStructSequence_Desc flags_desc = { flags__doc__, /* doc */ flags_fields, /* fields */ #ifdef RISCOS - 13 -#else 12 +#else + 11 #endif }; @@ -1356,7 +1355,6 @@ make_flags(void) PyStructSequence_SET_ITEM(seq, pos++, PyLong_FromLong(flag)) SetFlag(Py_DebugFlag); - SetFlag(Py_DivisionWarningFlag); SetFlag(Py_InspectFlag); SetFlag(Py_InteractiveFlag); SetFlag(Py_OptimizeFlag); -- cgit v1.2.1 From da93e1034d0920de202f9ff0e941cc76dfc3e925 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sat, 30 Apr 2011 14:53:09 +0200 Subject: Issue #11223: Replace threading._info() by sys.thread_info --- Python/sysmodule.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index fdf361fa8b..b549203536 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -17,6 +17,7 @@ Data members: #include "Python.h" #include "code.h" #include "frameobject.h" +#include "pythread.h" #include "osdefs.h" @@ -1251,20 +1252,21 @@ PyDoc_STR( "\n\ Static objects:\n\ \n\ -float_info -- a dict with information about the float implementation.\n\ +builtin_module_names -- tuple of module names built into this interpreter\n\ +copyright -- copyright notice pertaining to this interpreter\n\ +exec_prefix -- prefix used to find the machine-specific Python library\n\ +executable -- pathname of this Python interpreter\n\ +float_info -- a struct sequence with information about the float implementation.\n\ +float_repr_style -- string indicating the style of repr() output for floats\n\ +hexversion -- version information encoded as a single integer\n\ int_info -- a struct sequence with information about the int implementation.\n\ maxsize -- the largest supported length of containers.\n\ maxunicode -- the largest supported character\n\ -builtin_module_names -- tuple of module names built into this interpreter\n\ -version -- the version of this interpreter as a string\n\ -version_info -- version information as a named tuple\n\ -hexversion -- version information encoded as a single integer\n\ -copyright -- copyright notice pertaining to this interpreter\n\ platform -- platform identifier\n\ -executable -- pathname of this Python interpreter\n\ prefix -- prefix used to find the Python library\n\ -exec_prefix -- prefix used to find the machine-specific Python library\n\ -float_repr_style -- string indicating the style of repr() output for floats\n\ +thread_info -- a struct sequence with information about the thread implementation.\n\ +version -- the version of this interpreter as a string\n\ +version_info -- version information as a named tuple\n\ " ) #ifdef MS_WINDOWS @@ -1611,6 +1613,10 @@ _PySys_Init(void) PyUnicode_FromString("legacy")); #endif +#ifdef WITH_THREAD + SET_SYS_FROM_STRING("thread_info", PyThread_GetInfo()); +#endif + #undef SET_SYS_FROM_STRING if (PyErr_Occurred()) return NULL; -- cgit v1.2.1 From 2319ec2bcccdc5b2e8e051323423d9e4f96853c8 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Thu, 29 Sep 2011 00:18:19 +0300 Subject: #13054: sys.maxunicode is now always 0x10FFFF. --- Python/sysmodule.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index b549203536..dea21490e2 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1261,7 +1261,7 @@ float_repr_style -- string indicating the style of repr() output for floats\n\ hexversion -- version information encoded as a single integer\n\ int_info -- a struct sequence with information about the int implementation.\n\ maxsize -- the largest supported length of containers.\n\ -maxunicode -- the largest supported character\n\ +maxunicode -- the value of the largest Unicode codepoint\n\ platform -- platform identifier\n\ prefix -- prefix used to find the Python library\n\ thread_info -- a struct sequence with information about the thread implementation.\n\ @@ -1536,7 +1536,7 @@ _PySys_Init(void) SET_SYS_FROM_STRING("hash_info", get_hash_info()); SET_SYS_FROM_STRING("maxunicode", - PyLong_FromLong(PyUnicode_GetMax())); + PyLong_FromLong(0x10FFFF)); SET_SYS_FROM_STRING("builtin_module_names", list_builtin_module_names()); { -- cgit v1.2.1 From 687c3b16f72a6b2b64971c1c27e33e27f001ede8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 29 Sep 2011 00:42:28 +0200 Subject: Use the new Py_ARRAY_LENGTH macro --- Python/sysmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index dea21490e2..3576cedf63 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1771,7 +1771,7 @@ sys_update_path(int argc, wchar_t **argv) the argument must be the full path anyway. */ wchar_t *ptemp; if (GetFullPathNameW(argv0, - sizeof(fullpath)/sizeof(fullpath[0]), + Py_ARRAY_LENGTH(fullpath), fullpath, &ptemp)) { argv0 = fullpath; -- cgit v1.2.1 From dcacb24f386ae1b107462181af42b6826ec15fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sun, 9 Oct 2011 10:38:36 +0200 Subject: =?UTF-8?q?Add=20API=20for=20static=20strings,=20primarily=20good?= =?UTF-8?q?=20for=20identifiers.=20Thanks=20to=20Konrad=20Sch=C3=B6bel=20a?= =?UTF-8?q?nd=20Jasper=20Schulz=20for=20helping=20with=20the=20mass-editin?= =?UTF-8?q?g.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Python/sysmodule.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 3576cedf63..f0aceada5f 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -99,7 +99,8 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o) buffer = PyObject_GetAttrString(outf, "buffer"); if (buffer) { - result = PyObject_CallMethod(buffer, "write", "(O)", encoded); + _Py_identifier(write); + result = _PyObject_CallMethodId(buffer, &PyId_write, "(O)", encoded); Py_DECREF(buffer); Py_DECREF(encoded); if (result == NULL) -- cgit v1.2.1 From c3eb93fe1ce5f5ff2666fb9f34a6fd7c46279554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Mon, 10 Oct 2011 18:11:30 +0200 Subject: Use identifier API for PyObject_GetAttrString. --- Python/sysmodule.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index f0aceada5f..5195a4a79f 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -79,8 +79,10 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o) PyObject *encoded, *escaped_str, *repr_str, *buffer, *result; char *stdout_encoding_str; int ret; + _Py_identifier(encoding); + _Py_identifier(buffer); - stdout_encoding = PyObject_GetAttrString(outf, "encoding"); + stdout_encoding = _PyObject_GetAttrId(outf, &PyId_encoding); if (stdout_encoding == NULL) goto error; stdout_encoding_str = _PyUnicode_AsString(stdout_encoding); @@ -97,7 +99,7 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o) if (encoded == NULL) goto error; - buffer = PyObject_GetAttrString(outf, "buffer"); + buffer = _PyObject_GetAttrId(outf, &PyId_buffer); if (buffer) { _Py_identifier(write); result = _PyObject_CallMethodId(buffer, &PyId_write, "(O)", encoded); @@ -1841,11 +1843,12 @@ sys_pyfile_write_unicode(PyObject *unicode, PyObject *file) { PyObject *writer = NULL, *args = NULL, *result = NULL; int err; + _Py_identifier(write); if (file == NULL) return -1; - writer = PyObject_GetAttrString(file, "write"); + writer = _PyObject_GetAttrId(file, &PyId_write); if (writer == NULL) goto error; -- cgit v1.2.1 From f5ad3b280b43227eb0e3fa63d89490a58ba9c28b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Fri, 14 Oct 2011 10:20:37 +0200 Subject: Rename _Py_identifier to _Py_IDENTIFIER. --- Python/sysmodule.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 5195a4a79f..7a1933d994 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -79,8 +79,8 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o) PyObject *encoded, *escaped_str, *repr_str, *buffer, *result; char *stdout_encoding_str; int ret; - _Py_identifier(encoding); - _Py_identifier(buffer); + _Py_IDENTIFIER(encoding); + _Py_IDENTIFIER(buffer); stdout_encoding = _PyObject_GetAttrId(outf, &PyId_encoding); if (stdout_encoding == NULL) @@ -101,7 +101,7 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o) buffer = _PyObject_GetAttrId(outf, &PyId_buffer); if (buffer) { - _Py_identifier(write); + _Py_IDENTIFIER(write); result = _PyObject_CallMethodId(buffer, &PyId_write, "(O)", encoded); Py_DECREF(buffer); Py_DECREF(encoded); @@ -1843,7 +1843,7 @@ sys_pyfile_write_unicode(PyObject *unicode, PyObject *file) { PyObject *writer = NULL, *args = NULL, *result = NULL; int err; - _Py_identifier(write); + _Py_IDENTIFIER(write); if (file == NULL) return -1; -- cgit v1.2.1 From 406e4d8f1d3d003e8754d9e65607a697e7f5c865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Fri, 14 Oct 2011 15:16:45 +0200 Subject: Port SetAttrString/HasAttrString to SetAttrId/GetAttrId. --- Python/sysmodule.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 7a1933d994..6911c9aef6 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -139,6 +139,7 @@ sys_displayhook(PyObject *self, PyObject *o) PyObject *modules = interp->modules; PyObject *builtins = PyDict_GetItemString(modules, "builtins"); int err; + _Py_IDENTIFIER(_); if (builtins == NULL) { PyErr_SetString(PyExc_RuntimeError, "lost builtins module"); @@ -152,7 +153,7 @@ sys_displayhook(PyObject *self, PyObject *o) Py_INCREF(Py_None); return Py_None; } - if (PyObject_SetAttrString(builtins, "_", Py_None) != 0) + if (_PyObject_SetAttrId(builtins, &PyId__, Py_None) != 0) return NULL; outf = PySys_GetObject("stdout"); if (outf == NULL || outf == Py_None) { @@ -174,7 +175,7 @@ sys_displayhook(PyObject *self, PyObject *o) } if (PyFile_WriteString("\n", outf) != 0) return NULL; - if (PyObject_SetAttrString(builtins, "_", o) != 0) + if (_PyObject_SetAttrId(builtins, &PyId__, o) != 0) return NULL; Py_INCREF(Py_None); return Py_None; -- cgit v1.2.1 From 3d8b582274811ae53e65578f812a633429268d52 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 31 Oct 2011 11:48:09 +0100 Subject: Issue #13226: Update sys.setdlopenflags() docstring Refer to os.RTLD_xxx constants instead of ctypes and DLFCN modules. --- Python/sysmodule.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 6911c9aef6..ab0008e44c 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -775,9 +775,7 @@ interpreter loads extension modules. Among other things, this will enable\n\ a lazy resolving of symbols when importing a module, if called as\n\ sys.setdlopenflags(0). To share symbols across extension modules, call as\n\ sys.setdlopenflags(ctypes.RTLD_GLOBAL). Symbolic names for the flag modules\n\ -can be either found in the ctypes module, or in the DLFCN module. If DLFCN\n\ -is not available, it can be generated from /usr/include/dlfcn.h using the\n\ -h2py script."); +can be found in the os module (RTLD_xxx constants, e.g. os.RTLD_LAZY)."); static PyObject * sys_getdlopenflags(PyObject *self, PyObject *args) -- cgit v1.2.1