Bug 1456075 - import error in PyKDE4/__init__.py
Summary: import error in PyKDE4/__init__.py
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: pykde4
Version: 26
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Than Ngo
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-27 00:41 UTC by Herbert Carl Meyer
Modified: 2019-03-16 01:29 UTC (History)
4 users (show)

Fixed In Version: pykde4-4.14.3-21.fc26 pykde4-4.14.3-21.fc27
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-27 16:53:37 UTC
Type: Bug


Attachments (Terms of Use)
Patch which should hack around this issue (1.08 KB, patch)
2017-11-06 16:00 UTC, Jason Tibbitts
no flags Details | Diff

Description Herbert Carl Meyer 2017-05-27 00:41:33 UTC
Description of problem:

the import DLFCN has been removed from python 3.6

How reproducible:

100 %

Steps to Reproduce:

1. run a python pgm that uses PyKde4

Actual results:

Traceback (most recent call last):
  File "./ksokoban-ng.py", line 17, in <module>
    from PyKDE4.kdecore import ki18n, i18n, KAboutData, KCmdLineArgs, KStandardDirs, KConfig
  File "/usr/lib64/python3.6/site-packages/PyKDE4/__init__.py", line 1, in <module>
    import sys,DLFCN
ModuleNotFoundError: No module named 'DLFCN'

Expected results:

ksokoban-ng runs

Additional info:

DLFCN was removed from python 3.3, as it was undocumented. It contains constant values for dlopen flag values. 

see:

https://bugs.launchpad.net/ubuntu/+source/python3.3/+bug/1075891

I hit it after running Fedora 26 alpha. It did not appear in Fedora 25.

ksokoban-ng is a game I like.

Comment 1 Jason Tibbitts 2017-08-11 17:54:51 UTC
This has broken one of my local applications.  Ugh.

DLFCN was actually removed from python 3.6 upstream, but it can still be generated with h2py.  It seems to me as if that should be done as part of the main python package build process, but that would be up to the python maintainers.  I guess it they don't want to do so, the python3-pykde4 package could do so.

Until then I guess I can stub in a small package which contains it so that I can get my local application working again.

Comment 2 Herbert Carl Meyer 2017-08-22 01:01:21 UTC
Hacked it in by copying DLFCN.py into /usr/lib64/python3.6, and removing L from some integer constants, because integers default to long in python 3. 
Now I have a "RuntimeError: PyKDE4.kdeui cannot import type 'QList<QPair<QString,QString> >' from PyQt4.QtCore" to chase.

Comment 3 Jason Tibbitts 2017-08-22 01:25:06 UTC
Yes, that's https://bugzilla.redhat.com/show_bug.cgi?id=1480727

Comment 4 Jason Tibbitts 2017-11-06 15:50:56 UTC
So now that this is the only thing which appears to be holding me back from using PyKDE4 again, I tried to find a reasonable solution.

This package could simply generate and include DLFCN.py directly.  I guess it would work, but it's mildly hacky.

But actually looking at the code, we really only need two things.  This is the relevant __init__.py:

import sys,DLFCN
# This is needed to ensure that dynamic_cast and RTTI works inside kdelibs.
sys.setdlopenflags(DLFCN.RTLD_NOW|DLFCN.RTLD_GLOBAL)

So, why not just hardcode those two constants?

RTLD_NOW = 0x00002
RTLD_GLOBAL = 0x00100

Yeah, it's a hack.  You could extract them from /usr/include/bits/dlfcn.h during the build process if there was some concern that they would change, but the entire system would have far bigger problems if that happened.

Will attach a patch.

Comment 5 Jason Tibbitts 2017-11-06 16:00:32 UTC
Created attachment 1348657 [details]
Patch which should hack around this issue

Note that I did test this, but only with python3 as I don't have any python2 code which uses pykde4.  I also can't actually build PyKDE4 in mock currently, with or without this patch.  I guess I need things from testing.

Comment 6 Than Ngo 2018-01-15 15:04:12 UTC
it's fixed in pykde4-4.14.3-21.fc28. I will push it as update for f26/f27

Comment 7 Herbert Carl Meyer 2018-01-15 16:42:18 UTC
Thank you, Ngo. I will read the update. I am sure it is better than my hack to __init__.py

Comment 8 Jason Tibbitts 2018-01-17 23:17:12 UTC
Ah, so just removing the change to the ldopen flags is sufficient?  I wasn't ever sure if it could break some other component.

Comment 9 Jason Tibbitts 2018-02-12 23:00:50 UTC
It doesn't appear that an update was ever pushed.  I see that the change was committed to git (along with another one related to sip-4.19.5) and that a build was done but I don't see any actual update.

Comment 10 Fedora Update System 2018-02-13 03:47:41 UTC
pykde4-4.14.3-21.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2018-7ff28c3a4c

Comment 11 Fedora Update System 2018-02-13 04:24:19 UTC
pykde4-4.14.3-21.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2018-f91ef4dd4f

Comment 12 Fedora Update System 2018-02-13 16:21:58 UTC
pykde4-4.14.3-21.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-f91ef4dd4f

Comment 13 Fedora Update System 2018-02-13 16:42:03 UTC
pykde4-4.14.3-21.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-7ff28c3a4c

Comment 14 Fedora Update System 2018-02-27 16:53:37 UTC
pykde4-4.14.3-21.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2018-02-27 17:18:37 UTC
pykde4-4.14.3-21.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.

Comment 16 Herbert Carl Meyer 2019-03-16 01:29:27 UTC
bug has re-appeared in Fedora 30.

[hcmeyer@madmax ~]$ ksokobanNg.sh 
Traceback (most recent call last):
  File "./ksokoban-ng.py", line 17, in <module>
    from PyKDE4.kdecore import ki18n, i18n, KAboutData, KCmdLineArgs, KStandardDirs, KConfig
  File "/usr/lib64/python3.7/site-packages/PyKDE4/__init__.py", line 1, in <module>
    import sys,DLFCN
ModuleNotFoundError: No module named 'DLFCN'


Note You need to log in before you can comment on or make changes to this bug.