Re: GObject introspection & Python3



On Jul 09, 2011, at 12:25 PM, Daniel Drake wrote:

>Does anyone have real world experience in porting large apps to
>Python3 - anything we should be particularly aware of?

Not yet, but I still hope to port one or two desktop applications this Ubuntu
cycle as part of this blueprint:

https://blueprints.launchpad.net/ubuntu/+spec/foundations-o-python-versions

>As a test, I installed python3-gobject on Fedora 15 and tried to run
>this test app, which works fine with Python2:
>http://dev.laptop.org/~dsd/20110625/wkdemo.py
>
>It failed as follows:
>
>Traceback (most recent call last):
>  File "wkdemo.py", line 4, in <module>
>    from gi.repository import Gtk, WebKit
>  File "/usr/lib/python3.2/site-packages/gi/importer.py", line 76, in
>load_module
>    dynamic_module._load()
>  File "/usr/lib/python3.2/site-packages/gi/module.py", line 251, in _load
>    overrides_modules = __import__('gi.overrides', fromlist=[self._namespace])
>  File "/usr/lib/python3.2/site-packages/gi/overrides/Gtk.py", line
>400, in <module>
>    class MessageDialog(Gtk.MessageDialog, Dialog):
>  File "/usr/lib/python3.2/site-packages/gi/overrides/Gtk.py", line
>404, in MessageDialog
>    type=Gtk.MessageType.INFO,
>  File "/usr/lib/python3.2/site-packages/gi/module.py", line 127, in __getattr__
>    ascii_upper_trans = string.maketrans(
>AttributeError: 'module' object has no attribute 'maketrans'

Just call maketrans() directly on the str or bytes object:

Python 3.2.1 (default, Jul 10 2011, 21:50:35) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 'foo'.maketrans
<built-in function maketrans>
>>> b'foo'.maketrans
<built-in function maketrans>

Cheers,
-Barry

Attachment: signature.asc
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]