8000 bpo-35381 Remove all static state from posixmodule by eduardo-elizondo · Pull Request #15892 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-35381 Remove all static state from posixmodule #15892

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Nov 5, 2019
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e09cf81
Make Posixmodule use PyType_FromSpec
eduardo-elizondo Dec 3, 2018
40f0ff4
Added NEWS
eduardo-elizondo Dec 3, 2018
5be18a1
Updated hash
eduardo-elizondo Dec 3, 2018
9479848
Addressed PR Issues
eduardo-elizondo Jan 19, 2019
d31df5f
Rebased
eduardo-elizondo Jan 19, 2019
c84689c
Ran argument clinic
eduardo-elizondo Jan 19, 2019
796a8d7
Added NEWS
eduardo-elizondo Jan 19, 2019
b7cae5b
Remove INCREF from GenericAlloc
eduardo-elizondo Jan 19, 2019
5fa6e46
Make Posixmodule use PyType_FromSpec
eduardo-elizondo Dec 3, 2018
df178b4
Added NEWS
eduardo-elizondo Dec 3, 2018
e59208f
Updated hash
eduardo-elizondo Dec 3, 2018
def6467
Addressed PR Issues
eduardo-elizondo Jan 19, 2019
bb2ead8
Ran argument clinic
eduardo-elizondo Jan 19, 2019
427c772
Added NEWS
eduardo-elizondo Jan 19, 2019
7b9b85f
Merged to master
eduardo-elizondo Sep 11, 2019
9e8fb83
Merge branch 'master' into posixmodule-fromspec
eduardo-elizondo Sep 11, 2019
99d5c26
Cleaned up slot acces
eduardo-elizondo Sep 11, 2019
ca19f51
Cleaned up more slot accesses
eduardo-elizondo Sep 11, 2019
8af0c4e
Nits
eduardo-elizondo Sep 11, 2019
cee2cd9
Fixes
eduardo-elizondo Sep 11, 2019
a8d2f56
Run clinic
eduardo-elizondo Sep 11, 2019
5e4d2ab
Run clinic
eduardo-elizondo Sep 11, 2019
c42ec45
Improve error handling
encukou Sep 11, 2019
d27a547
Remove static from posixmodule.c
eduardo-elizondo Sep 12, 2019
6af98a9
Merge branch 'posixmodule-fromspec' of https://github.com/eduardo-eli…
eduardo-elizondo Sep 12, 2019
a723d1c
Address Comments
eduardo-elizondo Sep 12, 2019
e91096a
Address Comments
eduardo-elizondo Sep 12, 2019
3cf259e
Fix Windows build
eduardo-elizondo Sep 12, 2019
925a41e
Use interned strings for constants in module state
encukou Sep 13, 2019
ad7359b
Use descriptor directly, rather than look it up by name
encukou Sep 13, 2019
5de545d
Bring _Py_IDENTIFIER(__fspath__) back
encukou Sep 13, 2019
3ada298
Use the tp_free slot directly
encukou Sep 13, 2019
4c80b06
Remove duplicate function
encukou Sep 13, 2019
6e505ac
Use tp_new directly
encukou Sep 13, 2019
b9a49aa
Don't call PyState_AddModule
encukou Sep 13, 2019
c1a6d03
Add __new__ changes
eduardo-elizondo Sep 17, 2019
bbe887f
Merge branch 'master' into posixmodule-fromspec
eduardo-elizondo Sep 17, 2019
4a6d4ec
Regenerate clinic
eduardo-elizondo Sep 18, 2019
138ffb6
Nits
eduardo-elizondo Sep 23, 2019
78fbed3
Merge to master
eduardo-elizondo Nov 3, 2019
1b57f3a
Revert tp_new changes
eduardo-elizondo Nov 3, 2019
e7e9634
Rerun argument clinit
eduardo-elizondo Nov 3, 2019
3bf99bf
More fixes
eduardo-elizondo Nov 3, 2019
afb249c
Re-add newlines and fix docstring for os.sched_param.__new__
encukou Nov 5, 2019
187b5d4
Code style nitpicks
encukou Nov 5, 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
Prev Previous commit
Next Next commit
Bring _Py_IDENTIFIER(__fspath__) back
CPython doesn't yet have a good replacement for _Py_IDENTIFIER, but
reimplementing _PyObject_LookupSpecial in each module that needs it
is not the way to go.
This will need to be changed after we figure out _Py_IDENTIFIER more
systematically.
  • Loading branch information
encukou committed Sep 13, 2019
commit 5de545dad772680af53c93e5a8064ddb4edb0614
29 changes: 3 additions & 26 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ corresponding Unix manual entries for more information on calls.");
#endif /* _MSC_VER */
#endif /* ! __WATCOMC__ || __QNX__ */

_Py_IDENTIFIER(__fspath__);

/*[clinic input]
# one of the few times we lie about this name!
Expand Down Expand Up @@ -835,7 +836,6 @@ typedef struct {
PyObject *struct_rusage;
#endif
PyObject *st_mode;
PyObject *fspath;
newfunc structseq_new;
} _posixstate;

Expand Down Expand Up @@ -955,24 +955,6 @@ typedef struct {
{function_name, argument_name, nullable, allow_fd, NULL, NULL, -1, 0, NULL, NULL}
#endif

// _PyType_LookupSpecial with PyObject* rather than _Py_Identifier
static PyObject*
fspath_lookup_special(PyObject *self) {
PyObject *func, *getter;
PyTypeObject *path_type = Py_TYPE(self);
func = _PyType_Lookup(path_type, _posixstate_global->fspath);
if (func != NULL) {
getter = Py_TYPE(func)->tp_descr_get;
if (getter == NULL) {
Py_INCREF(func);
} else {
func = PyObject_CallFunctionObjArgs(
getter, func, self, (PyObject *)path_type, NULL);
}
}
return func;
}

static void
path_cleanup(path_t *path)
{
Expand Down Expand Up @@ -1032,7 +1014,7 @@ path_converter(PyObject *o, void *p)
/* Inline PyOS_FSPath() for better error messages. */
PyObject *func, *res;

func = fspath_lookup_special(o);
func = _PyObject_LookupSpecial(o, &PyId___fspath__);
if (NULL == func) {
goto error_format;
}
Expand Down Expand Up @@ -2151,7 +2133,6 @@ _posix_clear(PyObject *module)
Py_CLEAR(_posixstate(module)->struct_rusage);
#endif
Py_CLEAR(_posixstate(module)->st_mode);
Py_CLEAR(_posixstate(module)->fspath);
return 0;
}

Expand All @@ -2177,7 +2158,6 @@ _posix_traverse(PyObject *module, visitproc visit, void *arg)
Py_VISIT(_posixstate(module)->struct_rusage);
#endif
Py_VISIT(_posixstate(module)->st_mode);
Py_VISIT(_posixstate(module)->fspath);
return 0;
}

Expand Down Expand Up @@ -13395,7 +13375,7 @@ PyOS_FSPath(PyObject *path)
return path;
}

func = fspath_lookup_special(path);
func = _PyObject_LookupSpecial(path, &PyId___fspath__);
if (NULL == func) {
return PyErr_Format(PyExc_TypeError,
"expected str, bytes or os.PathLike object, "
Expand Down Expand Up @@ -14663,9 +14643,6 @@ INITFUNC(void)
_posixstate(m)->st_mode = PyUnicode_InternFromString("st_mode");
if (_posixstate(m)->st_mode == NULL)
return NULL;
_posixstate(m)->fspath = PyUnicode_InternFromString("__fspath__");
if (_posixstate(m)->fspath == NULL)
return NULL;

/* suppress "function not used" warnings */
{
Expand Down
0