Re: Annotations for command line arguments and environment variables



Short answer: "filename" seems correct to me. "filename" really is a
poorly named term that means "the current locale that filenames and
terminal text is encoded in". So, if you set your locale to
LANG=ru_RU.KOI8-R or LANG=ja_JP.SJIS, then text in your command line
should be encoded as such. If GTK+ really wants to handle arbitrary,
non-encoding-supported bytes in its command line arguments, well, it
can, I just think that's a really poor idea, especially in
higher-level languages.

Longer answer: The issue is that POSIX and Python 3 have different
views of the world.

POSIX says "bytes, bytes, everything is bytes. Do Unicode internally
if you really need it".

Python 3 says "Unicode please, bytes are for low-level system
hackers". Python 3 does not have a proper bytes string type. So,
Python's sys.argv is Unicode. It receives bytes through the C API, and
then decodes that internally using the same LANG environment
variables. PyGObject receives Unicode strings, and needs to figure out
which bytes to pass in a char*. GI gives you two options: use UTF-8
always. "filename" is the correct choice to convert Unicode strings
into an argv.

On Tue, Jun 7, 2016 at 10:28 AM, Christoph Reiter
<reiter christoph gmail com> wrote:
Hey everyone,

I'm currently trying to improve filename and argv/environ handling in
PyGObject and started annotating filenames as "filename" and also argv/environ
related arguments as "filename" as they are treated the same way in Python.

I've (among others) filed

https://bugzilla.gnome.org/show_bug.cgi?id=767266

and

https://bugzilla.gnome.org/show_bug.cgi?id=767268

where it was pointed out that argv/environ should maybe not be annotated as
filename and on IRC uint8 arrays were suggested instead. The later would
result in API breakage in PyGObject, but could be mostly worked around using
overrides.

So, I'm wondering how other bindings handle that issue and how an annotation
change for, say gtk_init() to either "filename" or "uint8 array" would affect
other bindings. Or if someone has a better idea.
_______________________________________________
gir-devel-list mailing list
gir-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gir-devel-list



-- 
  Jasper


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