Bug 91561

Summary: Nested class in waflib/Context.py causes pickle exception during build
Product: pycairo Reporter: Barry Warsaw <barry>
Component: generalAssignee: Steve Chaplin <d74n5pohf9>
Status: RESOLVED DUPLICATE QA Contact:
Severity: critical    
Priority: medium CC: dhgutteridge
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Move node_class to the module globals so it can be pickled.

Description Barry Warsaw 2015-08-04 21:22:54 UTC
Created attachment 117532 [details]
Move node_class to the module globals so it can be pickled.

In Debian/Ubuntu, we are building py3cairo 1.10.0.  With the transition to Python 3.5 currently ongoing in Ubuntu, a build failure has surfaced which actually affects Python 3.4 and 3.5, although we've only just noticed it.

The problem is that in waflib/Context.py, the Context class has a node_class nested inside the __init__.py.  Inside the __init__() it assigns this class to the self.node_class attribute.  The build process attempts to pickle the Context instance, but this nested class breaks that because it cannot be pickled.  Python cannot pickle classes which are nested inside methods because they cannot be unpickled; Python can't look up the class when it comes to unpickling it.  I'm rather surprised this ever built correctly.

The fix I'm applying for Ubuntu (and eventually Debian) is rather simple.  There's no obvious reason why node_class has to be nested inside __init__(), so I just moved it to being a module global.

See attached patch.
Comment 1 Barry Warsaw 2015-08-05 00:10:48 UTC
For some reason which I don't yet understand, this patch only fixed the py3cairo build on some, but not all platforms.

https://launchpad.net/ubuntu/+source/py3cairo/1.10.0+dfsg-4ubuntu1

It looks like we're still getting similar failures for arm64, powerpc, and ppc64el:

https://launchpadlibrarian.net/213608763/buildlog_ubuntu-wily-arm64.py3cairo_1.10.0%2Bdfsg-4ubuntu1_BUILDING.txt.gz

https://launchpadlibrarian.net/213606628/buildlog_ubuntu-wily-powerpc.py3cairo_1.10.0%2Bdfsg-4ubuntu1_BUILDING.txt.gz

https://launchpadlibrarian.net/213606734/buildlog_ubuntu-wily-ppc64el.py3cairo_1.10.0%2Bdfsg-4ubuntu1_BUILDING.txt.gz

I clearly have to better understand why this pickling is done, and why it would be different on different platform builds.

If you can provide insights, please get in touch!
Comment 2 Barry Warsaw 2015-08-05 22:08:27 UTC
This patch probably doesn't work correctly anyway.  After much pdb'ing I still don't understand how this is failing.
Comment 3 David H. Gutteridge 2015-12-12 07:27:36 UTC
This appears to be a duplicate of bug 76759. Probably both don't need to be open.
Comment 4 Christoph Reiter 2017-07-05 15:00:00 UTC
Since 1.11 pycairo uses distutils for building. If there are any problems with the new system please file a bug: https://github.com/pygobject/pycairo/issues

*** This bug has been marked as a duplicate of bug 76759 ***

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.