Skip to content
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

Additional debugging information for Acquisition error #61

Open
darryldixon opened this issue Apr 13, 2022 · 2 comments
Open

Additional debugging information for Acquisition error #61

darryldixon opened this issue Apr 13, 2022 · 2 comments

Comments

@darryldixon
Copy link

_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;
 }
@icemac
Copy link
Member

icemac commented Apr 13, 2022

@d-maurer What do you think about this proposed change?

@d-maurer
Copy link
Contributor

d-maurer commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants