diff options
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 52034ff7fb..416a02b546 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -108,7 +108,7 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o) { PyObject *stdout_encoding = NULL; PyObject *encoded, *escaped_str, *repr_str, *buffer, *result; - char *stdout_encoding_str; + const char *stdout_encoding_str; int ret; stdout_encoding = _PyObject_GetAttrId(outf, &PyId_encoding); @@ -1287,6 +1287,19 @@ a 11-tuple where the entries in the tuple are counts of:\n\ 10. Number of stack pops performed by call_function()" ); +static PyObject * +sys_callstats(PyObject *self) +{ + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "sys.callstats() has been deprecated in Python 3.7 " + "and will be removed in the future", 1) < 0) { + return NULL; + } + + Py_RETURN_NONE; +} + + #ifdef __cplusplus extern "C" { #endif @@ -1350,9 +1363,23 @@ PyDoc_STRVAR(is_finalizing_doc, Return True if Python is exiting."); +#ifdef ANDROID_API_LEVEL +PyDoc_STRVAR(getandroidapilevel_doc, +"getandroidapilevel()\n\ +\n\ +Return the build time API version of Android as an integer."); + +static PyObject * +sys_getandroidapilevel(PyObject *self) +{ + return PyLong_FromLong(ANDROID_API_LEVEL); +} +#endif /* ANDROID_API_LEVEL */ + + static PyMethodDef sys_methods[] = { /* Might as well keep this in alphabetic order */ - {"callstats", (PyCFunction)PyEval_GetCallStats, METH_NOARGS, + {"callstats", (PyCFunction)sys_callstats, METH_NOARGS, callstats_doc}, {"_clear_type_cache", sys_clear_type_cache, METH_NOARGS, sys_clear_type_cache__doc__}, @@ -1434,6 +1461,10 @@ static PyMethodDef sys_methods[] = { METH_VARARGS | METH_KEYWORDS, set_asyncgen_hooks_doc}, {"get_asyncgen_hooks", sys_get_asyncgen_hooks, METH_NOARGS, get_asyncgen_hooks_doc}, +#ifdef ANDROID_API_LEVEL + {"getandroidapilevel", (PyCFunction)sys_getandroidapilevel, METH_NOARGS, + getandroidapilevel_doc}, +#endif {NULL, NULL} /* sentinel */ }; @@ -1547,8 +1578,9 @@ error: Py_XDECREF(name); Py_XDECREF(value); /* No return value, therefore clear error state if possible */ - if (_PyThreadState_UncheckedGet()) + if (_PyThreadState_UncheckedGet()) { PyErr_Clear(); + } } PyObject * @@ -2293,7 +2325,7 @@ sys_pyfile_write_unicode(PyObject *unicode, PyObject *file) if (writer == NULL) goto error; - result = _PyObject_CallArg1(writer, unicode); + result = PyObject_CallFunctionObjArgs(writer, unicode, NULL); if (result == NULL) { goto error; } else { @@ -2403,7 +2435,7 @@ sys_format(_Py_Identifier *key, FILE *fp, const char *format, va_list va) { PyObject *file, *message; PyObject *error_type, *error_value, *error_traceback; - char *utf8; + const char *utf8; PyErr_Fetch(&error_type, &error_value, &error_traceback); file = _PySys_GetObjectId(key); |