Skip to content

Commit ac33aa7

Browse files
committed
better handling of 18n text
we were not decoding doc strings correctly from utf-8 in python2.7
1 parent 2ecaf2b commit ac33aa7

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* add some libvips 8.7 tests
1010
* move to pytest [kleis]
1111
* better handling of many-byte values in py3 new_from_memory [MatthiasKohl]
12+
* better handling of utf-8 i18n text [felixbuenemann]
1213

1314
## Version 2.1.2 (1 March 2018)
1415

pyvips/error.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def _to_bytes(x):
2222
call this on strings you pass to libvips.
2323
2424
"""
25-
2625
if isinstance(x, text_type):
2726
x = x.encode()
2827
return x
@@ -35,8 +34,11 @@ def _to_string(x):
3534
string. You must call this on text strings you get back from libvips.
3635
3736
"""
38-
if _is_PY3 and isinstance(x, bytes):
39-
x = x.decode('utf-8')
37+
if isinstance(x, bytes):
38+
if _is_PY3:
39+
x = x.decode('utf-8')
40+
else:
41+
x = unicode(x, 'utf-8')
4042
return x
4143

4244

pyvips/voperation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def generate_docstring(operation_name):
292292
result += ")\n"
293293

294294
def argstr(name):
295-
return (' {0} ({1}): {2}\n'.
295+
return (u' {0} ({1}): {2}\n'.
296296
format(name,
297297
GValue.gtype_to_python(op.get_typeof(name)),
298298
op.get_blurb(name)))

0 commit comments

Comments
 (0)