Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-36876: Avoid static locals.#13372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
11 commits
Select commitHold shift + click to select a range
5c7ad09
Fix static locals in helper modules.
ericsnowcurrentlyMay 15, 2019
df8c0d4
Fix static locals in testing modules.
ericsnowcurrentlyMay 15, 2019
a9cfc15
Fix static locals in builtin modules.
ericsnowcurrentlyMay 15, 2019
c4689e0
Fix static locals in stdlib extension modules.
ericsnowcurrentlyMay 15, 2019
6e9289c
Verify static locals in the parser code.
ericsnowcurrentlyMay 15, 2019
6dc09fa
Fix static locals for objects.
ericsnowcurrentlyMay 15, 2019
e21b68f
Fix static locals for core runtime code.
ericsnowcurrentlyMay 16, 2019
b1afab1
Move local _Py_IDENTIFER to global for modules.
ericsnowcurrentlyMay 16, 2019
6902106
Move local _Py_IDENTIFER to global for objects.
ericsnowcurrentlyMay 17, 2019
055fa11
Move local _Py_IDENTIFER to global for core files.
ericsnowcurrentlyMay 17, 2019
f9aca0c
Add a NEWS entry.
ericsnowcurrentlyMay 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Move away from static locals.
38 changes: 15 additions & 23 deletionsModules/_asynciomodule.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,21 @@ _Py_IDENTIFIER(current_task);
_Py_IDENTIFIER(get_event_loop);
_Py_IDENTIFIER(send);
_Py_IDENTIFIER(throw);
_Py_IDENTIFIER(get_loop);
_Py_IDENTIFIER(_loop);
_Py_IDENTIFIER(get_debug);
_Py_IDENTIFIER(PENDING);
_Py_IDENTIFIER(CANCELLED);
_Py_IDENTIFIER(FINISHED);
_Py_IDENTIFIER(_repr_info);
_Py_IDENTIFIER(call_exception_handler);
_Py_IDENTIFIER(message);
_Py_IDENTIFIER(exception);
_Py_IDENTIFIER(future);
_Py_IDENTIFIER(source_traceback);
_Py_IDENTIFIER(add);
_Py_IDENTIFIER(discard);
_Py_IDENTIFIER(task);


/* State of the _asyncio module */
Expand DownExpand Up@@ -202,8 +217,6 @@ get_future_loop(PyObject *fut)
{
/* Implementation of `asyncio.futures._get_loop` */

_Py_IDENTIFIER(get_loop);
_Py_IDENTIFIER(_loop);
PyObject *getloop;

if (Future_CheckExact(fut) || Task_CheckExact(fut)) {
Expand DownExpand Up@@ -469,7 +482,6 @@ future_init(FutureObj *fut, PyObject *loop)
{
PyObject *res;
int is_true;
_Py_IDENTIFIER(get_debug);

// Same to FutureObj_clear() but not clearing fut->dict
Py_CLEAR(fut->fut_loop);
Expand DownExpand Up@@ -1255,9 +1267,6 @@ FutureObj_get_source_traceback(FutureObj *fut, void *Py_UNUSED(ignored))
static PyObject *
FutureObj_get_state(FutureObj *fut, void *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(PENDING);
_Py_IDENTIFIER(CANCELLED);
_Py_IDENTIFIER(FINISHED);
PyObject *ret = NULL;

ENSURE_FUTURE_ALIVE(fut)
Expand DownExpand Up@@ -1294,8 +1303,6 @@ _asyncio_Future__repr_info_impl(FutureObj *self)
static PyObject *
FutureObj_repr(FutureObj *fut)
{
_Py_IDENTIFIER(_repr_info);

ENSURE_FUTURE_ALIVE(fut)

PyObject *rinfo = _PyObject_CallMethodIdObjArgs((PyObject*)fut,
Expand All@@ -1320,12 +1327,6 @@ FutureObj_repr(FutureObj *fut)
static void
FutureObj_finalize(FutureObj *fut)
{
_Py_IDENTIFIER(call_exception_handler);
_Py_IDENTIFIER(message);
_Py_IDENTIFIER(exception);
_Py_IDENTIFIER(future);
_Py_IDENTIFIER(source_traceback);

PyObject *error_type, *error_value, *error_traceback;
PyObject *context;
PyObject *message = NULL;
Expand DownExpand Up@@ -1845,8 +1846,6 @@ TaskWakeupMethWrapper_new(TaskObj *task)
static int
register_task(PyObject *task)
{
_Py_IDENTIFIER(add);

PyObject *res = _PyObject_CallMethodIdObjArgs(
all_tasks, &PyId_add, task, NULL);
if (res == NULL) {
Expand All@@ -1860,8 +1859,6 @@ register_task(PyObject *task)
static int
unregister_task(PyObject *task)
{
_Py_IDENTIFIER(discard);

PyObject *res = _PyObject_CallMethodIdObjArgs(
all_tasks, &PyId_discard, task, NULL);
if (res == NULL) {
Expand DownExpand Up@@ -2358,11 +2355,6 @@ _asyncio_Task_set_name(TaskObj *self, PyObject *value)
static void
TaskObj_finalize(TaskObj *task)
{
_Py_IDENTIFIER(call_exception_handler);
_Py_IDENTIFIER(task);
_Py_IDENTIFIER(message);
_Py_IDENTIFIER(source_traceback);

PyObject *context;
PyObject *message = NULL;
PyObject *func;
Expand Down
16 changes: 8 additions & 8 deletionsModules/_bisectmodule.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,15 +51,15 @@ bisect_right(PyObject *self, PyObject *args, PyObject *kw)
Py_ssize_t lo = 0;
Py_ssize_t hi = -1;
Py_ssize_t index;
static char *keywords[] = {"a", "x", "lo", "hi", NULL};
static char *kwlist[] = {"a", "x", "lo", "hi", NULL};

if (kw == NULL && PyTuple_GET_SIZE(args) == 2) {
list = PyTuple_GET_ITEM(args, 0);
item = PyTuple_GET_ITEM(args, 1);
}
else {
if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|nn:bisect_right",
keywords, &list, &item, &lo, &hi))
kwlist, &list, &item, &lo, &hi))
return NULL;
}
index = internal_bisect_right(list, item, lo, hi);
Expand DownExpand Up@@ -87,15 +87,15 @@ insort_right(PyObject *self, PyObject *args, PyObject *kw)
Py_ssize_t lo = 0;
Py_ssize_t hi = -1;
Py_ssize_t index;
static char *keywords[] = {"a", "x", "lo", "hi", NULL};
static char *kwlist[] = {"a", "x", "lo", "hi", NULL};

if (kw == NULL && PyTuple_GET_SIZE(args) == 2) {
list = PyTuple_GET_ITEM(args, 0);
item = PyTuple_GET_ITEM(args, 1);
}
else {
if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|nn:insort_right",
keywords, &list, &item, &lo, &hi))
kwlist, &list, &item, &lo, &hi))
return NULL;
}
index = internal_bisect_right(list, item, lo, hi);
Expand DownExpand Up@@ -168,15 +168,15 @@ bisect_left(PyObject *self, PyObject *args, PyObject *kw)
Py_ssize_t lo = 0;
Py_ssize_t hi = -1;
Py_ssize_t index;
static char *keywords[] = {"a", "x", "lo", "hi", NULL};
static char *kwlist[] = {"a", "x", "lo", "hi", NULL};

if (kw == NULL && PyTuple_GET_SIZE(args) == 2) {
list = PyTuple_GET_ITEM(args, 0);
item = PyTuple_GET_ITEM(args, 1);
}
else {
if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|nn:bisect_left",
keywords, &list, &item, &lo, &hi))
kwlist, &list, &item, &lo, &hi))
return NULL;
}
index = internal_bisect_left(list, item, lo, hi);
Expand DownExpand Up@@ -204,14 +204,14 @@ insort_left(PyObject *self, PyObject *args, PyObject *kw)
Py_ssize_t lo = 0;
Py_ssize_t hi = -1;
Py_ssize_t index;
static char *keywords[] = {"a", "x", "lo", "hi", NULL};
static char *kwlist[] = {"a", "x", "lo", "hi", NULL};

if (kw == NULL && PyTuple_GET_SIZE(args) == 2) {
list = PyTuple_GET_ITEM(args, 0);
item = PyTuple_GET_ITEM(args, 1);
} else {
if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|nn:insort_left",
keywords, &list, &item, &lo, &hi))
kwlist, &list, &item, &lo, &hi))
return NULL;
}
index = internal_bisect_left(list, item, lo, hi);
Expand Down
2 changes: 1 addition & 1 deletionModules/_blake2/impl/blake2-impl.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -131,7 +131,7 @@ BLAKE2_LOCAL_INLINE(uint64_t) rotr64( const uint64_t w, const unsigned c )
/* prevents compiler optimizing out memset() */
BLAKE2_LOCAL_INLINE(void) secure_zero_memory(void *v, size_t n)
{
static void *(*const volatile memset_v)(void *, int, size_t) = &memset;
static void *(*const volatile memset_v)(void *, int, size_t) = &memset; // Static is okay here (process-global).
memset_v(v, 0, n);
}

Expand Down
10 changes: 6 additions & 4 deletionsModules/_collectionsmodule.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,12 @@
#include <sys/types.h> /* For size_t */
#endif


_Py_IDENTIFIER(__dict__);
_Py_IDENTIFIER(items);
_Py_IDENTIFIER(get);
_Py_IDENTIFIER(__setitem__);

/*[clinic input]
class _tuplegetter "_tuplegetterobject *" "&tuplegetter_type"
[clinic start generated code]*/
Expand DownExpand Up@@ -1321,7 +1327,6 @@ static PyObject *
deque_reduce(dequeobject *deque, PyObject *Py_UNUSED(ignored))
{
PyObject *dict, *it;
_Py_IDENTIFIER(__dict__);

if (_PyObject_LookupAttrId((PyObject *)deque, &PyId___dict__, &dict) < 0) {
return NULL;
Expand DownExpand Up@@ -2031,7 +2036,6 @@ defdict_reduce(defdictobject *dd, PyObject *Py_UNUSED(ignored))
PyObject *items;
PyObject *iter;
PyObject *result;
_Py_IDENTIFIER(items);

if (dd->default_factory == NULL || dd->default_factory == Py_None)
args = PyTuple_New(0);
Expand DownExpand Up@@ -2236,8 +2240,6 @@ Count elements in the iterable, updating the mapping");
static PyObject *
_count_elements(PyObject *self, PyObject *args)
{
_Py_IDENTIFIER(get);
_Py_IDENTIFIER(__setitem__);
PyObject *it, *iterable, *mapping, *oldval;
PyObject *newval = NULL;
PyObject *key = NULL;
Expand Down
3 changes: 2 additions & 1 deletionModules/_csv.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,8 @@ module instead.
#include <stdbool.h>


_Py_IDENTIFIER(write);

typedef struct {
PyObject *error_obj; /* CSV exception */
PyObject *dialects; /* Dialect registry */
Expand DownExpand Up@@ -1365,7 +1367,6 @@ csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args)
{
PyObject * output_file, * dialect = NULL;
WriterObj * self = PyObject_GC_New(WriterObj, &Writer_Type);
_Py_IDENTIFIER(write);

if (!self)
return NULL;
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp