Re: Type of GtkEntry text property



Hello Manuel,

Manuel Quiñones [2012-06-18 18:51 -0300]:
> Hi, I was expecting that GtkEntry text property can handle Unicode
> automatically, and return Unicode too, storing UTF-8 encoded gchar* in
> the middle.  But seems to not be the case:

That's right for Python 3: all string arguments accept a "str" Python
data type (what used to be "unicode" in Python 2) and also return str.

But for Python 2, pygobject always takes and returns python 2's "str"
data type, which is an UTF-8 bytestring. Methods generally accept
"unicode" values as well and pygobject converts them to "str" on the
fly, but not the return values.

This will not ever change for Python 2, as this would be a dramatic
API change which would instantly break pretty much every pygobject
program out there. Fortunately Python 3 cleaned up the str/unicode
mess of Python 2, so if/once you use Python 3 it should be all good.

> >From IntrospectionPorting wiki page [1] this is one of the features of
> Overrides "Another important case is automatic data type conversion,
> most prominently to allow passing unicode objects to methods which
> expect an UTF-8 encoded gchar*. This also actually helps to prevent
> workarounds in application code and maintain a clean API".

Adding overrides for automatically converting unicode input values is
still fine. Changing return values is a no-go area (API break), please
see https://bugzilla.gnome.org/show_bug.cgi?id=663610 for a very
similar problem.

Thanks,

Martin
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)


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