Skip to content

Additional debugging information for Acquisition error #61

@darryldixon

Description

@darryldixon

_Acquisition.c has specific code for recognising when an Acquisition-wrapped item is being fed in to the Python Pickler, and it throws TypeError: "Can't pickle objects in acquisition wrappers." when this occurs.

The error is very opaque and difficult to track down what, actually, is being erroneously Acquisition wrapped and fed in to the Pickler. A sample (not Production-quality) improvement for this would be something like:

--- Acquisition-4.7/setup.py	2020-10-07 22:44:28.000000000 +1300
+++ Acquisition-4.7a/setup.py	2022-04-06 18:29:55.235552924 +1200
@@ -36,7 +36,7 @@
                   include_dirs=['include', 'src']),
     ]
 
-version = '4.7'
+version = '4.7a'
 
 setup(
     name='Acquisition',
diff -ru Acquisition-4.7/src/Acquisition/_Acquisition.c Acquisition-4.7a/src/Acquisition/_Acquisition.c
--- Acquisition-4.7/src/Acquisition/_Acquisition.c	2020-10-07 22:44:28.000000000 +1300
+++ Acquisition-4.7a/src/Acquisition/_Acquisition.c	2022-04-07 00:14:47.942013701 +1200
@@ -1477,8 +1477,16 @@
 PyObject *
 Wrappers_are_not_picklable(PyObject *wrapper, PyObject *args)
 {
+    PyObject *obj;
+    PyObject *repr;
+    /* C progammers disease... */
+    char msg[1024];
+    /* Unwrap wrapper completely -> obj. */
+    obj = get_base(wrapper);
+    repr = PyObject_Repr((PyObject *)obj);
+    snprintf(msg, 1024, "Can't pickle objects in acquisition wrappers - %s", (char *)PyBytes_AS_STRING(repr));
     PyErr_SetString(PyExc_TypeError,
-                    "Can't pickle objects in acquisition wrappers.");
+                    msg);
     return NULL;
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions