Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
d2fdd1fe
Unverified
Kaydet (Commit)
d2fdd1fe
authored
Mar 15, 2019
tarafından
Eric Snow
Kaydeden (comit)
GitHub
Mar 15, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-36124: Add PyInterpreterState.dict. (gh-12132)
üst
c11183cd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
2 deletions
+40
-2
init.rst
Doc/c-api/init.rst
+12
-0
pycore_pystate.h
Include/internal/pycore_pystate.h
+2
-0
pystate.h
Include/pystate.h
+8
-2
2019-03-01-13-48-01.bpo-36124.Blzxq1.rst
...ore and Builtins/2019-03-01-13-48-01.bpo-36124.Blzxq1.rst
+4
-0
pystate.c
Python/pystate.c
+14
-0
No files found.
Doc/c-api/init.rst
Dosyayı görüntüle @
d2fdd1fe
...
...
@@ -1026,6 +1026,18 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
.. versionadded:: 3.7
.. c:function:: PyObject* PyInterpreterState_GetDict(PyInterpreterState *interp)
Return a dictionary in which interpreter-specific data may be stored.
If this function returns *NULL* then no exception has been raised and
the caller should assume no interpreter-specific dict is available.
This is not a replacement for :c:func:`PyModule_GetState()`, which
extensions should use to store interpreter-specific state information.
.. versionadded:: 3.8
.. c:function:: PyObject* PyThreadState_GetDict()
Return a dictionary in which extensions can store thread-specific state
...
...
Include/internal/pycore_pystate.h
Dosyayı görüntüle @
d2fdd1fe
...
...
@@ -63,6 +63,8 @@ struct _is {
int
dlopenflags
;
#endif
PyObject
*
dict
;
/* Stores per-interpreter state */
PyObject
*
builtins_copy
;
PyObject
*
import_func
;
/* Initialized to PyEval_EvalFrameDefault(). */
...
...
Include/pystate.h
Dosyayı görüntüle @
d2fdd1fe
...
...
@@ -24,17 +24,23 @@ typedef struct _ts PyThreadState;
/* struct _is is defined in internal/pycore_pystate.h */
typedef
struct
_is
PyInterpreterState
;
/* State unique per thread */
PyAPI_FUNC
(
PyInterpreterState
*
)
PyInterpreterState_New
(
void
);
PyAPI_FUNC
(
void
)
PyInterpreterState_Clear
(
PyInterpreterState
*
);
PyAPI_FUNC
(
void
)
PyInterpreterState_Delete
(
PyInterpreterState
*
);
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03080000
/* New in 3.8 */
PyAPI_FUNC
(
PyObject
*
)
PyInterpreterState_GetDict
(
PyInterpreterState
*
);
#endif
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
/* New in 3.7 */
PyAPI_FUNC
(
int64_t
)
PyInterpreterState_GetID
(
PyInterpreterState
*
);
#endif
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
/* State unique per thread */
/* New in 3.3 */
PyAPI_FUNC
(
int
)
PyState_AddModule
(
PyObject
*
,
struct
PyModuleDef
*
);
PyAPI_FUNC
(
int
)
PyState_RemoveModule
(
struct
PyModuleDef
*
);
...
...
Misc/NEWS.d/next/Core and Builtins/2019-03-01-13-48-01.bpo-36124.Blzxq1.rst
0 → 100644
Dosyayı görüntüle @
d2fdd1fe
Add a new interpreter-specific dict and expose it in the C-API via
PyInterpreterState_GetDict(). This parallels PyThreadState_GetDict().
However, extension modules should continue using PyModule_GetState() for
their own internal per-interpreter state.
Python/pystate.c
Dosyayı görüntüle @
d2fdd1fe
...
...
@@ -224,6 +224,7 @@ PyInterpreterState_Clear(PyInterpreterState *interp)
Py_CLEAR
(
interp
->
builtins_copy
);
Py_CLEAR
(
interp
->
importlib
);
Py_CLEAR
(
interp
->
import_func
);
Py_CLEAR
(
interp
->
dict
);
#ifdef HAVE_FORK
Py_CLEAR
(
interp
->
before_forkers
);
Py_CLEAR
(
interp
->
after_forkers_parent
);
...
...
@@ -462,6 +463,19 @@ _PyInterpreterState_GetMainModule(PyInterpreterState *interp)
return
PyMapping_GetItemString
(
interp
->
modules
,
"__main__"
);
}
PyObject
*
PyInterpreterState_GetDict
(
PyInterpreterState
*
interp
)
{
if
(
interp
->
dict
==
NULL
)
{
interp
->
dict
=
PyDict_New
();
if
(
interp
->
dict
==
NULL
)
{
PyErr_Clear
();
}
}
/* Returning NULL means no per-interpreter dict is available. */
return
interp
->
dict
;
}
/* Default implementation for _PyThreadState_GetFrame */
static
struct
_frame
*
threadstate_getframe
(
PyThreadState
*
self
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment