summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-11-06 21:36:40 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-11-06 21:36:40 (GMT)
commitd67bd45537856a097d807e2b781fcaf60c68b89f (patch)
tree30239d2e232075d5886a62e4cd5117b6e0eda546 /Python/sysmodule.c
parentb44562b6b90c4974ac11aae2caec227295679363 (diff)
downloadcpython-d67bd45537856a097d807e2b781fcaf60c68b89f.zip
cpython-d67bd45537856a097d807e2b781fcaf60c68b89f.tar.gz
cpython-d67bd45537856a097d807e2b781fcaf60c68b89f.tar.bz2
Issue #19512: Add _PySys_GetObjectId() and _PySys_SetObjectId() functions
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index b8cf31d..32136e8 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -42,6 +42,16 @@ extern const char *PyWin_DLLVersionString;
#endif
PyObject *
+_PySys_GetObjectId(_Py_Identifier *key)
+{
+ PyThreadState *tstate = PyThreadState_GET();
+ PyObject *sd = tstate->interp->sysdict;
+ if (sd == NULL)
+ return NULL;
+ return _PyDict_GetItemId(sd, key);
+}
+
+PyObject *
PySys_GetObject(const char *name)
{
PyThreadState *tstate = PyThreadState_GET();
@@ -52,6 +62,21 @@ PySys_GetObject(const char *name)
}
int
+_PySys_SetObjectId(_Py_Identifier *key, PyObject *v)
+{
+ PyThreadState *tstate = PyThreadState_GET();
+ PyObject *sd = tstate->interp->sysdict;
+ if (v == NULL) {
+ if (_PyDict_GetItemId(sd, key) == NULL)
+ return 0;
+ else
+ return _PyDict_DelItemId(sd, key);
+ }
+ else
+ return _PyDict_SetItemId(sd, key, v);
+}
+
+int
PySys_SetObject(const char *name, PyObject *v)
{
PyThreadState *tstate = PyThreadState_GET();