pykdeuic4's processUi() calls compileUi() with 3 args instead of the 4 required by PyQt4.uic.Compiler.compiler

Bug #695590 reported by Alex Mayorga
82
This bug affects 10 people
Affects Status Importance Assigned to Milestone
KDE Bindings
Unknown
High
kdebindings (Ubuntu)
Fix Released
Medium
Unassigned
Natty
Fix Released
Medium
Unassigned

Bug Description

1. Impact: .ui files are not compiled into .py files. Instead a Python traceback is output and the resulting .py file is mostly blank (a bit of explanatory "this file was generated" text is all that's there)

2. How it's fixed: Modify the compileUi() call to include an additional argument ("False") to satisfy the API change in Qt.Compiler

3. Patch: see http://people.ubuntu.com/~maco.m/needs_sponsorship/kdebindings_4.6.2b-0ubuntu2.dsc

4. TEST CASE
1. See attached .ui file
2. pykdeuic4 -o ui_twoPanes.py twoPanes.ui

Expected result:
- no traceback crashy Python output
- ui_twoPanes.py has lots of Python inside

(Bad result = crashy Python output and mostly blank ui_TwoPanes.py)

5. No known regression potential. Patch is coming from upstream.

=====

Symptoms are the following in a build log:

Traceback (most recent call last):
  File "/usr/bin/pykdeuic4", line 148, in <module>
    main()
  File "/usr/bin/pykdeuic4", line 145, in main
    processUI(args[0], output_filename, exe)
  File "/usr/bin/pykdeuic4", line 74, in processUI
    winfo = comp.compileUi(uifile, output)
TypeError: compileUi() takes exactly 4 arguments (3 given)

Followed by an ImportError when the application being built is eventually run.

Revision history for this message
Alex Mayorga (alex-mayorga) wrote :
Revision history for this message
Mackenzie Morgan (maco.m) wrote : Re: [Bug 695590] [NEW] ImportError: cannot import name Ui_TwoPanes

Does the file /usr/share/pyshared/gally/twoPanes.py exist on your system?

Revision history for this message
Hans Joachim Desserud (hjd) wrote : Re: ImportError: cannot import name Ui_TwoPanes

I get the same error when attempting to run gally on Ubuntu Natty.

The file /usr/share/pyshared/gally/twoPanes.py exists.

Changed in gally (Ubuntu):
status: New → Confirmed
Revision history for this message
Mackenzie Morgan (maco.m) wrote :

Note to self: pykdeuic4 syntax may have changed based on:

running build_py
Traceback (most recent call last):
  File "/usr/bin/pykdeuic4", line 148, in <module>
    main()
  File "/usr/bin/pykdeuic4", line 145, in main
    processUI(args[0], output_filename, exe)
  File "/usr/bin/pykdeuic4", line 74, in processUI
    winfo = comp.compileUi(uifile, output)
TypeError: compileUi() takes exactly 4 arguments (3 given)

Changed in gally (Ubuntu):
assignee: nobody → Mackenzie Morgan (maco.m)
importance: Undecided → Medium
status: Confirmed → Triaged
Revision history for this message
In , Kevin-kofler (kevin-kofler) wrote :

Version: unspecified (using KDE 4.6.1)
OS: Linux

pykdeuic4 in kdebindings 4.6.x doesn't work with PyQt4 4.8.2 which it supposedly requires. See: https://bugzilla.redhat.com/show_bug.cgi?id=684419

Reproducible: Always

Steps to Reproduce:
1.create ui file with qt-designer
2.pykdeuic4 -o file.py file.ui

Actual Results:
Traceback

Expected Results:
No traceback

At first you get:

Traceback (most recent call last):
  File "/usr/bin/pykdeuic4", line 148, in <module>
    main()
  File "/usr/bin/pykdeuic4", line 145, in main
    processUI(args[0], output_filename, exe)
  File "/usr/bin/pykdeuic4", line 74, in processUI
    winfo = comp.compileUi(uifile, output)
TypeError: compileUi() takes exactly 4 arguments (3 given)

This is fixed in master, so it can be fixed by backporting:
https://projects.kde.org/projects/kde/kdebindings/pykde4/repository/revisions/3d84be0316c62136aa02f6a0a5482652d9582242

But that only gets you until the next traceback:

Traceback (most recent call last):
  File "/usr/bin/pykdeuic4", line 148, in <module>
    main()
  File "/usr/bin/pykdeuic4", line 145, in main
    processUI(args[0], output_filename, exe)
  File "/usr/bin/pykdeuic4", line 74, in processUI
    winfo = comp.compileUi(uifile, output, None)
  File "/usr/lib64/python2.7/site-packages/PyQt4/uic/Compiler/compiler.py",
line 119, in compileUi
    w = self.parse(input_stream)
  File "/usr/lib64/python2.7/site-packages/PyQt4/uic/uiparser.py", line 879, in
parse
    actor(elem)
  File "/usr/lib64/python2.7/site-packages/PyQt4/uic/uiparser.py", line 720, in
createUserInterface
    self.wprops.setProperties(self.toplevelWidget, elem)
  File "/usr/lib64/python2.7/site-packages/PyQt4/uic/properties.py", line 403,
in setProperties
    prop_value = self.convert(prop, widget)
  File "/usr/lib64/python2.7/site-packages/PyQt4/uic/properties.py", line 368,
in convert
    return func(prop[0], **args)
  File "/usr/lib64/python2.7/site-packages/PyQt4/uic/properties.py", line 148,
in _string
    prop.get('comment'), QtGui.QApplication.UnicodeUTF8)
  File "/usr/lib64/python2.7/site-packages/PyQt4/uic/Compiler/qtproxies.py",
line 238, in translate
    return i18n_string(text or "", disambig)
TypeError: __init__() takes exactly 2 arguments (3 given)

which doesn't appear to be fixed in master either.

Revision history for this message
In , Gökçen Eraslan (gkcn) wrote :

What about that:

https://svn.pardus.org.tr/pardus/2011/devel/desktop/kde/base/kdebindings/files/fix-pykdeuic4.patch

First hunk changing the __init__ method is not included in the mainstream commit. Can you check that solves your problem? If so, I can commit it.

Revision history for this message
In , Than (than) wrote :

Gökcen, the fix resolves the reported issue, it can be committed in upstream. thanks

Revision history for this message
Mackenzie Morgan (maco.m) wrote :

More discoveries:
compileUi() is called by processUi() in pykdeuic4 using 2 arguments (+implied "self"). It needs 1 more argument. compileUi() is defined in PyQt4.uic.Compiler.compiler

Changing package to python-kde4 since that's where the (apparently broken) pykdeuic4 lives

affects: gally (Ubuntu) → python-kde4 (Ubuntu)
Revision history for this message
Mackenzie Morgan (maco.m) wrote :

PyQt4.uic.Compiler.compile contains this line:
def compileUi(self, input_stream, output_stream, from_imports):

the "from_imports" arg is what's missing from pykdeuic4's call to compileUi()

Revision history for this message
Mackenzie Morgan (maco.m) wrote :
summary: - ImportError: cannot import name Ui_TwoPanes
+ pykdeuic4's processUi() calls compileUi() with 3 args instead of the 4
+ required by PyQt4.uic.Compiler.compiler
description: updated
Revision history for this message
Mackenzie Morgan (maco.m) wrote :

Attaching a test case. After installing python-kde4 from ppa:maco.m/ppa (same as the source package here: http://people.ubuntu.com/~maco.m/needs_sponsorship/kdebindings_4.6.2b-0ubuntu2.dsc but with a ~ppa1, feel free to rebuild), use the attached .ui file as such:

pykdeuic4 -o ui_twoPanes.py twoPanes.ui

Expected result:
- no traceback crashy Python output
- ui_twoPanes.py has lots of Python inside

(Bad result = crashy Python output and mostly blank ui_TwoPanes.py)

description: updated
affects: python-kde4 (Ubuntu) → kdebindings (Ubuntu)
Revision history for this message
Scott Kitterman (kitterman) wrote :

Uploaded. Waiting for ubuntu-sru review.

Changed in kdebindings (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Accepted kdebindings into natty-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

tags: added: verification-needed
Changed in kdebindings:
importance: Unknown → High
status: Unknown → Confirmed
Revision history for this message
Felix Geyer (debfx) wrote :

Compiling the attached ui file with python-kde4-dev 4:4.6.2b-0ubuntu1.1 works fine.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package kdebindings - 4:4.6.2b-0ubuntu1.1

---------------
kdebindings (4:4.6.2b-0ubuntu1.1) natty-proposed; urgency=low

  * Make pykdeuic4 compatible with new PyQt.Compiler (LP: #695590)
 -- Mackenzie Morgan <email address hidden> Sun, 24 Apr 2011 00:04:26 -0400

Changed in kdebindings (Ubuntu Natty):
status: Fix Committed → Fix Released
Revision history for this message
Martin Pitt (pitti) wrote :

Copied to oneiric as well.

Changed in kdebindings (Ubuntu):
status: Fix Committed → Fix Released
tags: added: testcase
Changed in kdebindings (Ubuntu):
assignee: Mackenzie Morgan (maco.m) → nobody
Changed in kdebindings (Ubuntu Natty):
assignee: Mackenzie Morgan (maco.m) → nobody
Changed in kdebindings:
status: Confirmed → Unknown
Revision history for this message
In , Andrew-crouthamel (andrew-crouthamel) wrote :

Hello, unfortunately this bug is being closed as unmaintained, per request of einar77.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.