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 from1 commit
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
PrevPrevious commit
NextNext commit
Move local _Py_IDENTIFER to global for objects.
  • Loading branch information
@ericsnowcurrently
ericsnowcurrently committedMay 17, 2019
commit6902106fda421d6f573a54b56937fe409c11ca4e
23 changes: 12 additions & 11 deletionsObjects/abstract.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,18 @@
#include "longintrepr.h"


_Py_IDENTIFIER(__bases__);
_Py_IDENTIFIER(__class__);
_Py_IDENTIFIER(__class_getitem__);
_Py_IDENTIFIER(__format__);
_Py_IDENTIFIER(__instancecheck__);
_Py_IDENTIFIER(__length_hint__);
_Py_IDENTIFIER(__subclasscheck__);
_Py_IDENTIFIER(__trunc__);
_Py_IDENTIFIER(items);
_Py_IDENTIFIER(keys);
_Py_IDENTIFIER(values);


/* Shorthands to return certain errors */

Expand DownExpand Up@@ -87,7 +99,6 @@ PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue)
{
PyObject *hint, *result;
Py_ssize_t res;
_Py_IDENTIFIER(__length_hint__);
if (_PyObject_HasLen(o)) {
res = PyObject_Length(o);
if (res < 0) {
Expand DownExpand Up@@ -173,7 +184,6 @@ PyObject_GetItem(PyObject *o, PyObject *key)

if (PyType_Check(o)) {
PyObject *meth, *result, *stack[1] = {key};
_Py_IDENTIFIER(__class_getitem__);
if (_PyObject_LookupAttrId(o, &PyId___class_getitem__, &meth) < 0) {
return NULL;
}
Expand DownExpand Up@@ -700,7 +710,6 @@ PyObject_Format(PyObject *obj, PyObject *format_spec)
PyObject *meth;
PyObject *empty = NULL;
PyObject *result = NULL;
_Py_IDENTIFIER(__format__);

if (format_spec != NULL && !PyUnicode_Check(format_spec)) {
PyErr_Format(PyExc_SystemError,
Expand DownExpand Up@@ -1355,7 +1364,6 @@ PyNumber_Long(PyObject *o)
PyNumberMethods *m;
PyObject *trunc_func;
Py_buffer view;
_Py_IDENTIFIER(__trunc__);

if (o == NULL) {
return null_error();
Expand DownExpand Up@@ -2227,7 +2235,6 @@ method_output_as_list(PyObject *o, _Py_Identifier *meth_id)
PyObject *
PyMapping_Keys(PyObject *o)
{
_Py_IDENTIFIER(keys);

if (o == NULL) {
return null_error();
Expand All@@ -2241,7 +2248,6 @@ PyMapping_Keys(PyObject *o)
PyObject *
PyMapping_Items(PyObject *o)
{
_Py_IDENTIFIER(items);

if (o == NULL) {
return null_error();
Expand All@@ -2255,7 +2261,6 @@ PyMapping_Items(PyObject *o)
PyObject *
PyMapping_Values(PyObject *o)
{
_Py_IDENTIFIER(values);

if (o == NULL) {
return null_error();
Expand DownExpand Up@@ -2295,7 +2300,6 @@ PyMapping_Values(PyObject *o)
static PyObject *
abstract_get_bases(PyObject *cls)
{
_Py_IDENTIFIER(__bases__);
PyObject *bases;

Py_ALLOW_RECURSION
Expand DownExpand Up@@ -2365,7 +2369,6 @@ recursive_isinstance(PyObject *inst, PyObject *cls)
{
PyObject *icls;
int retval;
_Py_IDENTIFIER(__class__);

if (PyType_Check(cls)) {
retval = PyObject_TypeCheck(inst, (PyTypeObject *)cls);
Expand DownExpand Up@@ -2401,7 +2404,6 @@ recursive_isinstance(PyObject *inst, PyObject *cls)
int
PyObject_IsInstance(PyObject *inst, PyObject *cls)
{
_Py_IDENTIFIER(__instancecheck__);
PyObject *checker;

/* Quick test for an exact match */
Expand DownExpand Up@@ -2476,7 +2478,6 @@ recursive_issubclass(PyObject *derived, PyObject *cls)
int
PyObject_IsSubclass(PyObject *derived, PyObject *cls)
{
_Py_IDENTIFIER(__subclasscheck__);
PyObject *checker;

/* We know what type's __subclasscheck__ does. */
Expand Down
6 changes: 4 additions & 2 deletionsObjects/bytearrayobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,10 @@
#include "bytesobject.h"
#include "pystrhex.h"


_Py_IDENTIFIER(__dict__);
_Py_IDENTIFIER(iter);

/*[clinic input]
class bytearray "PyByteArrayObject *" "&PyByteArray_Type"
[clinic start generated code]*/
Expand DownExpand Up@@ -2037,7 +2041,6 @@ static PyObject *
_common_reduce(PyByteArrayObject *self, int proto)
{
PyObject *dict;
_Py_IDENTIFIER(__dict__);
char *buf;

dict = _PyObject_GetAttrId((PyObject *)self, &PyId___dict__);
Expand DownExpand Up@@ -2349,7 +2352,6 @@ PyDoc_STRVAR(length_hint_doc,
static PyObject *
bytearrayiter_reduce(bytesiterobject *it, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(iter);
if (it->it_seq != NULL) {
return Py_BuildValue("N(O)n", _PyEval_GetBuiltinId(&PyId_iter),
it->it_seq, it->it_index);
Expand Down
7 changes: 4 additions & 3 deletionsObjects/bytesobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,10 @@
#include "pystrhex.h"
#include <stddef.h>


_Py_IDENTIFIER(__bytes__);
_Py_IDENTIFIER(iter);

/*[clinic input]
class bytes "PyBytesObject *" "&PyBytes_Type"
[clinic start generated code]*/
Expand DownExpand Up@@ -543,7 +547,6 @@ static PyObject *
format_obj(PyObject *v, const char **pbuf, Py_ssize_t *plen)
{
PyObject *func, *result;
_Py_IDENTIFIER(__bytes__);
/* is it a bytes object? */
if (PyBytes_Check(v)) {
*pbuf = PyBytes_AS_STRING(v);
Expand DownExpand Up@@ -2536,7 +2539,6 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *func;
Py_ssize_t size;
static char *kwlist[] = {"source", "encoding", "errors", 0};
_Py_IDENTIFIER(__bytes__);

if (type != &PyBytes_Type)
return bytes_subtype_new(type, args, kwds);
Expand DownExpand Up@@ -3110,7 +3112,6 @@ PyDoc_STRVAR(length_hint_doc,
static PyObject *
striter_reduce(striterobject *it, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(iter);
if (it->it_seq != NULL) {
return Py_BuildValue("N(O)n", _PyEval_GetBuiltinId(&PyId_iter),
it->it_seq, it->it_index);
Expand Down
4 changes: 3 additions & 1 deletionObjects/classobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,9 @@
#include "pycore_pystate.h"
#include "structmember.h"


_Py_IDENTIFIER(getattr);

#define TP_DESCR_GET(t) ((t)->tp_descr_get)

/* Free list for method objects to safe malloc/free overhead
Expand DownExpand Up@@ -80,7 +83,6 @@ method_reduce(PyMethodObject *im, PyObject *Py_UNUSED(ignored))
PyObject *self = PyMethod_GET_SELF(im);
PyObject *func = PyMethod_GET_FUNCTION(im);
PyObject *funcname;
_Py_IDENTIFIER(getattr);

funcname = _PyObject_GetAttrId(func, &PyId___name__);
if (funcname == NULL) {
Expand Down
4 changes: 3 additions & 1 deletionObjects/complexobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,9 @@
#include "Python.h"
#include "structmember.h"


_Py_IDENTIFIER(__complex__);

/*[clinic input]
class complex "PyComplexObject *" "&PyComplex_Type"
[clinic start generated code]*/
Expand DownExpand Up@@ -277,7 +280,6 @@ static PyObject *
try_complex_special_method(PyObject *op)
{
PyObject *f;
_Py_IDENTIFIER(__complex__);

f = _PyObject_LookupSpecial(op, &PyId___complex__);
if (f) {
Expand Down
19 changes: 10 additions & 9 deletionsObjects/descrobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,16 @@
#include "pycore_tupleobject.h"
#include "structmember.h" /* Why is this not included in Python.h? */


_Py_IDENTIFIER(__doc__);
_Py_IDENTIFIER(__qualname__);
_Py_IDENTIFIER(copy);
_Py_IDENTIFIER(get);
_Py_IDENTIFIER(getattr);
_Py_IDENTIFIER(items);
_Py_IDENTIFIER(keys);
_Py_IDENTIFIER(values);

/*[clinic input]
class mappingproxy "mappingproxyobject *" "&PyDictProxy_Type"
class property "propertyobject *" "&PyProperty_Type"
Expand DownExpand Up@@ -411,7 +421,6 @@ static PyObject *
calculate_qualname(PyDescrObject *descr)
{
PyObject *type_qualname, *res;
_Py_IDENTIFIER(__qualname__);

if (descr->d_name == NULL || !PyUnicode_Check(descr->d_name)) {
PyErr_SetString(PyExc_TypeError,
Expand DownExpand Up@@ -448,7 +457,6 @@ descr_get_qualname(PyDescrObject *descr, void *Py_UNUSED(ignored))
static PyObject *
descr_reduce(PyDescrObject *descr, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(getattr);
return Py_BuildValue("N(OO)", _PyEval_GetBuiltinId(&PyId_getattr),
PyDescr_TYPE(descr), PyDescr_NAME(descr));
}
Expand DownExpand Up@@ -852,7 +860,6 @@ static PyObject *
mappingproxy_get(mappingproxyobject *pp, PyObject *args)
{
PyObject *key, *def = Py_None;
_Py_IDENTIFIER(get);

if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &def))
return NULL;
Expand All@@ -863,28 +870,24 @@ mappingproxy_get(mappingproxyobject *pp, PyObject *args)
static PyObject *
mappingproxy_keys(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(keys);
return _PyObject_CallMethodId(pp->mapping, &PyId_keys, NULL);
}

static PyObject *
mappingproxy_values(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(values);
return _PyObject_CallMethodId(pp->mapping, &PyId_values, NULL);
}

static PyObject *
mappingproxy_items(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(items);
return _PyObject_CallMethodId(pp->mapping, &PyId_items, NULL);
}

static PyObject *
mappingproxy_copy(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(copy);
return _PyObject_CallMethodId(pp->mapping, &PyId_copy, NULL);
}

Expand DownExpand Up@@ -1078,7 +1081,6 @@ wrapper_repr(wrapperobject *wp)
static PyObject *
wrapper_reduce(wrapperobject *wp, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(getattr);
return Py_BuildValue("N(OO)", _PyEval_GetBuiltinId(&PyId_getattr),
wp->self, PyDescr_NAME(wp->descr));
}
Expand DownExpand Up@@ -1461,7 +1463,6 @@ property_init_impl(propertyobject *self, PyObject *fget, PyObject *fset,

/* if no docstring given and the getter has one, use that one */
if ((doc == NULL || doc == Py_None) && fget != NULL) {
_Py_IDENTIFIER(__doc__);
PyObject *get_doc = _PyObject_GetAttrId(fget, &PyId___doc__);
if (get_doc) {
if (Py_TYPE(self) == &PyProperty_Type) {
Expand Down
16 changes: 9 additions & 7 deletionsObjects/dictobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -116,6 +116,15 @@ converting the dict to the combined table.
#include "dict-common.h"
#include "stringlib/eq.h" /* to get unicode_eq() */


_Py_IDENTIFIER(__missing__);
_Py_IDENTIFIER(difference_update);
_Py_IDENTIFIER(intersection_update);
_Py_IDENTIFIER(iter);
_Py_IDENTIFIER(keys);
_Py_IDENTIFIER(symmetric_difference_update);
_Py_IDENTIFIER(update);

/*[clinic input]
class dict "PyDictObject *" "&PyDict_Type"
[clinic start generated code]*/
Expand DownExpand Up@@ -2109,7 +2118,6 @@ dict_subscript(PyDictObject *mp, PyObject *key)
if (!PyDict_CheckExact(mp)) {
/* Look up __missing__ method if we're a subclass. */
PyObject *missing, *res;
_Py_IDENTIFIER(__missing__);
missing = _PyObject_LookupSpecial((PyObject *)mp, &PyId___missing__);
if (missing != NULL) {
res = PyObject_CallFunctionObjArgs(missing,
Expand DownExpand Up@@ -2317,7 +2325,6 @@ dict_update_common(PyObject *self, PyObject *args, PyObject *kwds,
result = -1;
}
else if (arg != NULL) {
_Py_IDENTIFIER(keys);
PyObject *func;
if (_PyObject_LookupAttrId(arg, &PyId_keys, &func) < 0) {
result = -1;
Expand DownExpand Up@@ -3910,7 +3917,6 @@ dict___reversed___impl(PyDictObject *self)
static PyObject *
dictiter_reduce(dictiterobject *di, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(iter);
/* copy the iterator state */
dictiterobject tmp = *di;
Py_XINCREF(tmp.di_dict);
Expand DownExpand Up@@ -4154,7 +4160,6 @@ dictviews_sub(PyObject* self, PyObject *other)
{
PyObject *result = PySet_New(self);
PyObject *tmp;
_Py_IDENTIFIER(difference_update);

if (result == NULL)
return NULL;
Expand All@@ -4174,7 +4179,6 @@ _PyDictView_Intersect(PyObject* self, PyObject *other)
{
PyObject *result = PySet_New(self);
PyObject *tmp;
_Py_IDENTIFIER(intersection_update);

if (result == NULL)
return NULL;
Expand All@@ -4194,7 +4198,6 @@ dictviews_or(PyObject* self, PyObject *other)
{
PyObject *result = PySet_New(self);
PyObject *tmp;
_Py_IDENTIFIER(update);

if (result == NULL)
return NULL;
Expand All@@ -4214,7 +4217,6 @@ dictviews_xor(PyObject* self, PyObject *other)
{
PyObject *result = PySet_New(self);
PyObject *tmp;
_Py_IDENTIFIER(symmetric_difference_update);

if (result == NULL)
return NULL;
Expand Down
4 changes: 3 additions & 1 deletionObjects/enumobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,9 @@

#include "clinic/enumobject.c.h"


_Py_IDENTIFIER(__reversed__);

/*[clinic input]
class enumerate "enumobject *" "&PyEnum_Type"
class reversed "reversedobject *" "&PyReversed_Type"
Expand DownExpand Up@@ -273,7 +276,6 @@ reversed_new_impl(PyTypeObject *type, PyObject *seq)
Py_ssize_t n;
PyObject *reversed_meth;
reversedobject *ro;
_Py_IDENTIFIER(__reversed__);

reversed_meth = _PyObject_LookupSpecial(seq, &PyId___reversed__);
if (reversed_meth == Py_None) {
Expand Down
5 changes: 3 additions & 2 deletionsObjects/exceptions.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,9 @@
#include "osdefs.h"


_Py_IDENTIFIER(name);
_Py_IDENTIFIER(path);

/* Compatibility aliases */
PyObject *PyExc_EnvironmentError = NULL;
PyObject *PyExc_IOError = NULL;
Expand DownExpand Up@@ -699,8 +702,6 @@ ImportError_getstate(PyImportErrorObject *self)
{
PyObject *dict = ((PyBaseExceptionObject *)self)->dict;
if (self->name || self->path) {
_Py_IDENTIFIER(name);
_Py_IDENTIFIER(path);
dict = dict ? PyDict_Copy(dict) : PyDict_New();
if (dict == NULL)
return NULL;
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp