Lines 1-46
Link Here
|
1 |
--- lib/glib.py.orig 2016-01-15 19:42:55 UTC |
|
|
2 |
+++ lib/glib.py |
3 |
@@ -1,5 +1,5 @@ |
4 |
# This file is part of MyPaint. |
5 |
-# Copyright (C) 2015 by Andrew Chadwick <a.t.chadwick@gmail.com> |
6 |
+# Copyright (C) 2015-2016 by the MyPaint Development Team. |
7 |
# |
8 |
# This program is free software; you can redistribute it and/or modify |
9 |
# it under the terms of the GNU General Public License as published by |
10 |
@@ -19,11 +19,12 @@ unicode, and may not even be UTF-8). Thi |
11 |
## Imports |
12 |
|
13 |
import sys |
14 |
-from logging import getLogger |
15 |
-logger = getLogger(__name__) |
16 |
+import logging |
17 |
|
18 |
from gi.repository import GLib |
19 |
|
20 |
+logger = logging.getLogger(__name__) |
21 |
+ |
22 |
|
23 |
## File path getter functions |
24 |
|
25 |
@@ -35,7 +36,6 @@ def filename_to_unicode(opsysstring): |
26 |
:returns: the converted filename |
27 |
:rtype: unicode |
28 |
|
29 |
- >>> from gi.repository import GLib |
30 |
>>> filename_to_unicode('/ascii/only/path') |
31 |
u'/ascii/only/path' |
32 |
>>> filename_to_unicode(None) is None |
33 |
@@ -54,7 +54,12 @@ def filename_to_unicode(opsysstring): |
34 |
# Other systems are dependent in opaque ways on the environment. |
35 |
if not isinstance(opsysstring, str): |
36 |
raise TypeError("Argument must be bytes") |
37 |
- ustring = GLib.filename_to_utf8(opsysstring, -1, 0, 0) |
38 |
+ # This function's annotation seems to vary quite a bit. |
39 |
+ # See https://github.com/mypaint/mypaint/issues/634 |
40 |
+ try: |
41 |
+ ustring, _, _ = GLib.filename_to_utf8(opsysstring, -1) |
42 |
+ except TypeError: |
43 |
+ ustring = GLib.filename_to_utf8(opsysstring, -1, 0, 0) |
44 |
if ustring is None: |
45 |
raise UnicodeDecodeError( |
46 |
"GLib failed to convert %r to a UTF-8 string. " |