Content-Length: 391174 | pFad | http://github.com/python/cpython/pull/115566/commits/1e8b6ade48fac7539b3cde573cc26204ac9605ca

6D gh-76785: Update test.support.interpreters to Align With PEP 734 by ericsnowcurrently · Pull Request #115566 · python/cpython · GitHub
Skip to content

gh-76785: Update test.support.interpreters to Align With PEP 734 #115566

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 19 commits into from
Feb 28, 2024
Merged
Changes from 1 commit
Commits
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
Revert "Add pickle as a supported format."
This reverts commit 90085abb8812c1231f96d5b8c7288c1f2c4410aa.
  • Loading branch information
ericsnowcurrently committed Feb 27, 2024
commit 1e8b6ade48fac7539b3cde573cc26204ac9605ca
61 changes: 8 additions & 53 deletions Modules/_xxinterpqueuesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,7 @@ idarg_int64_converter(PyObject *arg, void *ptr)

/* module state *************************************************************/

struct cached_deps {
PyObject *picklemod;
};

static PyObject *
get_picklemod(struct cached_deps *cached)
{
PyObject *picklemod = cached->picklemod;
if (picklemod == NULL) {
picklemod = PyImport_ImportModule("pickle");
if (picklemod == NULL) {
return NULL;
}
cached->picklemod = picklemod;
}
return picklemod;
}

typedef struct {
struct cached_deps cached;

/* external types (added at runtime by interpreters module) */
PyTypeObject *queue_type;

Expand All @@ -173,8 +153,6 @@ get_module_state(PyObject *mod)
static int
traverse_module_state(module_state *state, visitproc visit, void *arg)
{
Py_VISIT(state->cached.picklemod);

/* external types */
Py_VISIT(state->queue_type);

Expand All @@ -190,8 +168,6 @@ traverse_module_state(module_state *state, visitproc visit, void *arg)
static int
clear_module_state(module_state *state)
{
Py_CLEAR(state->cached.picklemod);

/* external types */
Py_CLEAR(state->queue_type);

Expand Down Expand Up @@ -344,22 +320,14 @@ handle_queue_error(int err, PyObject *mod, int64_t qid)

enum item_format {
ITEM_FORMAT_SHARED,
ITEM_FORMAT_PICKLED,
};

static PyObject *
convert_object(PyObject *obj, enum item_format fmt, struct cached_deps *cached)
convert_object(PyObject *obj, enum item_format fmt)
{
if (fmt == ITEM_FORMAT_SHARED) {
return Py_NewRef(obj);
}
else if (fmt == ITEM_FORMAT_PICKLED) {
PyObject *picklemod = get_picklemod(cached);
if (picklemod == NULL) {
return NULL;
}
return PyObject_CallMethod(picklemod, "dumps", "O", obj);
}
else {
assert(0 && "format not implemented");
Py_FatalError("format not implemented");
Expand All @@ -368,18 +336,11 @@ convert_object(PyObject *obj, enum item_format fmt, struct cached_deps *cached)
}

static PyObject *
unconvert_object(PyObject *obj, enum item_format fmt, struct cached_deps *cached)
unconvert_object(PyObject *obj, enum item_format fmt)
{
if (fmt == ITEM_FORMAT_SHARED) {
return obj;
}
else if (fmt == ITEM_FORMAT_PICKLED) {
PyObject *picklemod = get_picklemod(cached);
if (picklemod == NULL) {
return NULL;
}
return PyObject_CallMethod(picklemod, "loads", "O", obj);
}
else {
assert(0 && "format not implemented");
Py_FatalError("format not implemented");
Expand Down Expand Up @@ -1005,8 +966,7 @@ queue_destroy(_queues *queues, int64_t qid)

// Push an object onto the queue.
static int
queue_put(_queues *queues, int64_t qid, PyObject *obj, enum item_format fmt,
struct cached_deps *cached)
queue_put(_queues *queues, int64_t qid, PyObject *obj, enum item_format fmt)
{
// Look up the queue.
_queue *queue = NULL;
Expand All @@ -1016,7 +976,7 @@ queue_put(_queues *queues, int64_t qid, PyObject *obj, enum item_format fmt,
}
assert(queue != NULL);

obj = convert_object(obj, fmt, cached);
obj = convert_object(obj, fmt);
if (obj == NULL) {
return -1;
}
Expand Down Expand Up @@ -1050,8 +1010,7 @@ queue_put(_queues *queues, int64_t qid, PyObject *obj, enum item_format fmt,
// Pop the next object off the queue. Fail if empty.
// XXX Support a "wait" mutex?
static int
queue_get(_queues *queues, int64_t qid, PyObject **res,
struct cached_deps *cached)
queue_get(_queues *queues, int64_t qid, PyObject **res)
{
int err;
*res = NULL;
Expand Down Expand Up @@ -1095,7 +1054,7 @@ queue_get(_queues *queues, int64_t qid, PyObject **res,
return -1;
}

PyObject *actual = unconvert_object(obj, fmt, cached);
PyObject *actual = unconvert_object(obj, fmt);
if (actual == NULL) {
Py_DECREF(obj);
return -1;
Expand Down Expand Up @@ -1481,10 +1440,8 @@ queuesmod_put(PyObject *self, PyObject *args, PyObject *kwds)
return NULL;
}

module_state *state = get_module_state(self);

/* Queue up the object. */
int err = queue_put(&_globals.queues, qid, obj, fmt, &state->cached);
int err = queue_put(&_globals.queues, qid, obj, fmt);
if (handle_queue_error(err, self, qid)) {
return NULL;
}
Expand All @@ -1509,10 +1466,8 @@ queuesmod_get(PyObject *self, PyObject *args, PyObject *kwds)
}
int64_t qid = qidarg.id;

module_state *state = get_module_state(self);

PyObject *obj = NULL;
int err = queue_get(&_globals.queues, qid, &obj, &state->cached);
int err = queue_get(&_globals.queues, qid, &obj);
if (err == ERR_QUEUE_EMPTY && dflt != NULL) {
assert(obj == NULL);
obj = Py_NewRef(dflt);
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/pull/115566/commits/1e8b6ade48fac7539b3cde573cc26204ac9605ca

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy