Skip to content

Commit 5e09055

Browse files
committed
fix using Unicode on Python 2
1 parent 3aa0c5a commit 5e09055

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
===========
22
Changelog
33
===========
4+
current
5+
* fixed errors with Unicode literals on Python 2
6+
47
1.5.0
58
* python-tdl distributions are now universal builds
69
* new Map class
710
* map.bresenham now returns a list
8-
* this release will require libtcod-cffi 0.2.3 or later
11+
* this release will require libtcod-cffi v0.2.3 or later
912

1013
1.4.0
1114
* The DLL's have been moved into another library which you can find at https://github.com/HexDecimal/libtcod-cffi

tdl/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
@undocumented: style
6060
"""
6161

62+
from __future__ import (absolute_import, division,
63+
print_function, unicode_literals)
64+
6265
import sys as _sys
6366
import os as _os
6467

@@ -86,11 +89,11 @@
8689
else:
8790
_INTTYPES = (int, long)
8891
_NUMTYPES = (int, long, float)
89-
_STRTYPES = (str,)
92+
_STRTYPES = (str, unicode)
9093

9194
def _encodeString(string): # still used for filepaths, and that's about it
9295
"changes string into bytes if running in python 3, for sending to ctypes"
93-
if _IS_PYTHON3 and isinstance(string, str):
96+
if isinstance(string, _STRTYPES):
9497
return string.encode()
9598
return string
9699

@@ -108,7 +111,7 @@ def _format_char(char):
108111
try:
109112
return int(char) # allow all int-like objects
110113
except:
111-
raise TypeError('char single character string, integer, or None\nReceived: ' + repr(color))
114+
raise TypeError('char single character string, integer, or None\nReceived: ' + repr(char))
112115

113116
_utf32_codec = {'little': 'utf-32le', 'big': 'utf-32le'}[_sys.byteorder]
114117

0 commit comments

Comments
 (0)