summaryrefslogtreecommitdiff
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-12-02 01:13:46 +0100
committerVictor Stinner <victor.stinner@gmail.com>2016-12-02 01:13:46 +0100
commitd6958ac6c0fec90524bf9c4999c8bc75fff0c71b (patch)
tree93f5e47349d8b51b9cec9f2c1710b8dc1e13c98b /Python/sysmodule.c
parentedfe8869c8e888e676091c87330b3bf0f3d9814b (diff)
downloadcpython-git-d6958ac6c0fec90524bf9c4999c8bc75fff0c71b.tar.gz
Add sys.getandroidapilevel()
Issue #28740: Add sys.getandroidapilevel(): return the build time API version of Android as an integer. Function only available on Android.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 2a3f36c6dd..19a3850a59 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1363,6 +1363,20 @@ 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)sys_callstats, METH_NOARGS,
@@ -1447,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 */
};