Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 390607 - app-text/pdfshuffler-0.5.1 - NameError: global name 'pixbuf' is not defined
Summary: app-text/pdfshuffler-0.5.1 - NameError: global name 'pixbuf' is not defined
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-15 11:04 UTC by b1254633
Modified: 2012-02-29 23:55 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emergeinfo,4.54 KB, text/plain)
2011-11-15 15:15 UTC, b1254633
Details
a few pdfshuffler fixes - pygtk version (pdfshuffler-no-pixbuf.patch,5.29 KB, patch)
2011-11-18 03:03 UTC, Rafał Mużyło
Details | Diff
introspection port attempt (pdfshuffler-introspection.patch,37.38 KB, patch)
2011-11-18 03:29 UTC, Rafał Mużyło
Details | Diff
more minimal poppler-0.18 compat (pdfshuffler-poppler-0.18.patch,1.78 KB, patch)
2012-02-28 23:47 UTC, Marien Zwart (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description b1254633 2011-11-15 11:04:09 UTC
when i import pdf i get this error
Gtk-Message: Failed to load module "gnomebreakpad"
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/bin/pdfshuffler", line 964, in run
    thumbnail = self.load_pdf_thumbnail(pdfdoc, npage, angle, crop)
  File "/usr/bin/pdfshuffler", line 1010, in load_pdf_thumbnail
    pixbuf.fill(0xffffffff)
NameError: global name 'pixbuf' is not defined

Reproducible: Always
Comment 1 Rafał Mużyło 2011-11-15 13:08:58 UTC
Given the *stunning* amount of info provided, it's rather hard to say anything conclusive, but the first guess would go to bug 377063.
Comment 2 b1254633 2011-11-15 15:15:54 UTC
Created attachment 292641 [details]
emerge --info
Comment 3 b1254633 2011-11-15 15:18:43 UTC
Version of poppler on my gentoo box

app-text/poppler-0.16.7
dev-python/python-poppler-0.12.1-r1
Comment 4 Rafał Mużyło 2011-11-15 17:09:30 UTC
...well, the other possibility is that the pdf in question has been created with a broken version of simple-scan (it's been producing broken pdfs until quite recently).

Of course, the fact, that the line
pixbuf.fill(0xffffffff)
should have been
thumbnail.fill(0xffffffff)
is an independent matter.
Comment 5 Jeroen Roovers (RETIRED) gentoo-dev 2011-11-15 17:28:25 UTC
At a wild guess, it looks like it cannot initialise a pixel buffer, so that might cause output to default to something blank when the import error is ignored. Maybe a matter of running python-updater?
Comment 6 b1254633 2011-11-15 21:47:12 UTC
I ran python-updater, but it doesn't work.

I tried a lot of pdf, but the result doesn't change...
Comment 7 Rafał Mużyło 2011-11-15 23:25:05 UTC
Honestly, see https://bugzilla.redhat.com/show_bug.cgi?id=705153, then read bug 377063 for the reason why the solution proposed there is not applicable.

Also, while I copy-pasted the code from poppler to python-poppler, I still think, that the real solution would be implementing the code in pdfshuffler - python-poppler was meant to be a wrapper, not provide its own API.
Comment 8 Rafał Mużyło 2011-11-18 03:03:49 UTC
Created attachment 292959 [details, diff]
a few pdfshuffler fixes - pygtk version

Just for the kicks - this patch for pdfshuffler makes it stop using render_to_pixbuf method.
It touches a few other things too - i.e. it ensures tracebacks are still printed in that part of code, as the total suppression made it a pain to modify.
Comment 9 Rafał Mużyło 2011-11-18 03:29:16 UTC
Created attachment 292961 [details, diff]
introspection port attempt

...and on top of the previous patch, this one moves pdfshuffler from pygtk/python-poppler to introspection for both.

It's very much a work in progress, but it seems to be *mostly* working - though as I'm not exactly a pdfshuffler user, I can't really say if I didn't miss a part or two (most likely I did).

It seems a bit slower on load, as I needed to move it from threading to idle and so interface is updated only after the file is completely loaded - I think this part can be done better.
Comment 10 Matt Summers (RETIRED) gentoo-dev 2011-12-14 17:55:32 UTC
Just to note, the solution appears to be the removal of one of the patches to python-poppler which overrides the behavior of pixbuf. I will test this and see.

For reference, here is the redhat/fedora bug that discusses the solution.

https://bugzilla.redhat.com/show_bug.cgi?id=705153

I have also confirmed this bug and assigned it to the python team.

Thanks!
Comment 11 Matt Summers (RETIRED) gentoo-dev 2011-12-14 18:11:15 UTC
I can now confirm that the removal of the "${FILESDIR}"/${P}-76_75.diff patch from dev-python/python-poppler fixes pdfshuffler. However, I do not know if it breaks anything else that depends on python-poppler
Comment 12 Rafał Mużyło 2011-12-14 19:20:08 UTC
(In reply to comment #10)
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=705153
> 
I already said in comment 7, that due to changes in poppler 0.18, solution from that bug is incorrect.
Comment 13 Matt Summers (RETIRED) gentoo-dev 2011-12-14 19:28:50 UTC
(In reply to comment #12)
> (In reply to comment #10)
> > 
> > https://bugzilla.redhat.com/show_bug.cgi?id=705153
> > 
> I already said in comment 7, that due to changes in poppler 0.18, solution from
> that bug is incorrect.

Rafał, this fix has been committed for dev-python/python-poppler-0.12.1-r2 which is a solution for stable packages. The changes required for poppler-0.18.x will be considered separately. 

I have seen a patch for 0.18.x compat here: https://bugs.launchpad.net/poppler-python/+bug/776234

That will take some time to work out for pdfshuffler, I suspect, due to GDK pixbuf functions removal. Hopefully upstream has some ideas.
Comment 14 Rafał Mużyło 2011-12-14 21:25:28 UTC
(In reply to comment #13)
> Rafał, this fix has been committed for dev-python/python-poppler-0.12.1-r2
> which is a solution for stable packages. The changes required for
> poppler-0.18.x will be considered separately. 
> 
> I have seen a patch for 0.18.x compat here:
> https://bugs.launchpad.net/poppler-python/+bug/776234
> 
> That will take some time to work out for pdfshuffler, I suspect, due to GDK
> pixbuf functions removal. Hopefully upstream has some ideas.

There are a few gotchas:
- poppler falls (mostly) under kde herd - at least as far as stabilization goes - and tends to get stabilized at most unfortunate moments

- the "patch" you've mentioned simply removes those gdk functions (to be honest, just like it should), so it *will* break pdfshufler as it it now

- as for pdfshuffler, patch from comment 7 is (AFAICT) complete in regard of gdk api removal (even if it needs a bit polish)

- bug 377063 seems to be the last blocking bug 384885 ATM, so I wouldn't be surprised, if - given the status of python-poppler - it got ignored as soon as the herd decides poppler stabilization is desired
Comment 15 Rafał Mużyło 2011-12-14 21:26:43 UTC
...I've meant "patch in comment 8", obviously.
Comment 16 Matt Summers (RETIRED) gentoo-dev 2011-12-14 22:21:32 UTC
(In reply to comment #14)
> (In reply to comment #13)
> > Rafał, this fix has been committed for dev-python/python-poppler-0.12.1-r2
> > which is a solution for stable packages. The changes required for
> > poppler-0.18.x will be considered separately. 
> > 
> > I have seen a patch for 0.18.x compat here:
> > https://bugs.launchpad.net/poppler-python/+bug/776234
> > 
> > That will take some time to work out for pdfshuffler, I suspect, due to GDK
> > pixbuf functions removal. Hopefully upstream has some ideas.
> 
> There are a few gotchas:
> - poppler falls (mostly) under kde herd - at least as far as stabilization goes
> - and tends to get stabilized at most unfortunate moments
> 

Noted, I will put myself in that loop as necessary.

> - the "patch" you've mentioned simply removes those gdk functions (to be
> honest, just like it should), so it *will* break pdfshufler as it it now
> 

Yep. But it fixes python-poppler correctly for poppler-0.18.x which is good.

> - as for pdfshuffler, patch from comment 7 is (AFAICT) complete in regard of
> gdk api removal (even if it needs a bit polish)
> 

As far as the patch, I have not reviewed it. Here is the deal, that sort of patch needs to go upstream to the author of pdfshuffler. From the looks of his svn log he is responsive to contributions, so first thing to do is to try to get your patch upstream. Work with the author a bit to get the required fixes included in his next release. In the case that upstream does not want to incorporate appropriate code to fix this issue for forwards compatibility, then we may address alternative solutions then. I need this package, so its going to get fixed at one point or another.

> - bug 377063 seems to be the last blocking bug 384885 ATM, so I wouldn't be
> surprised, if - given the status of python-poppler - it got ignored as soon as
> the herd decides poppler stabilization is desired

I do not share your pessimism. Most often when things get ignored it's due to a lack of communication.
Comment 17 Marien Zwart (RETIRED) gentoo-dev 2012-02-28 23:47:36 UTC
Created attachment 303647 [details, diff]
more minimal poppler-0.18 compat

This is a simplified version of attachment #292959 [details, diff]. I would like to just commit this: upstream svn does not have this bug (revision 60 fixes it, see sourceforge bug #3346212), but fixes it properly by using cairo ImageSurfaces instead of gdk Pixbufs throughout (and a custom cellrenderer to draw them). That is a change I think is too large to backport, and I think this fix is safe enough to use instead of a snapshot.

If nobody objects I will commit this in a few days or so, as pdfshuffler is maintainer-needed.

Many thanks to Rafał Mużyło for writing the patch this one is based on, but I really did not want to do the pixel format conversion by hand in Python, esp. without being able to test the bigendian case. This seems to get gdk to do it for us.
Comment 18 Dirkjan Ochtman (RETIRED) gentoo-dev 2012-02-29 08:37:42 UTC
Will you remove the import traceback; traceback.print_exc() again?
Comment 19 Marien Zwart (RETIRED) gentoo-dev 2012-02-29 13:57:25 UTC
I can, but that will lead to white/missing thumbnails with no indication of what went wrong if either the original code or my changes break. Note the added print is in an "except:" block that should not be hit at all unless there's already breakage. I'd prefer to keep it.
Comment 20 Dirkjan Ochtman (RETIRED) gentoo-dev 2012-02-29 14:34:40 UTC
Okay, sounds good then; go ahead.
Comment 21 Marien Zwart (RETIRED) gentoo-dev 2012-02-29 23:55:11 UTC
I've now committed this.