coding error in maskededitctrl wxPython 2.5.1.5u

An Error occurs when I type an accentuated characters in a MaskedTextCtrl and locale.setlocale(locale.LC_ALL, '')

Traceback (most recent call last):
  File "C:\soft\PYTHON23\lib\site-packages\wx\lib\maskededit.py", line 2797, in
_OnChar
    if keep_processing and self._isCharAllowed( chr(key), pos, checkRegex = True
):
  File "C:\soft\PYTHON23\lib\site-packages\wx\lib\maskededit.py", line 4336, in
_isCharAllowed
    newvalue, ignore, ignore, ignore, ignore = self._insertKey(char, at, sel_sta
rt, sel_to, value, allowAutoSelect=True)
  File "C:\soft\PYTHON23\lib\site-packages\wx\lib\maskededit.py", line 4790, in
_insertKey
    newtext = left + char + right
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 0: ordinal
not in range(128)

In fact at line 4790 the string concatenation is made between 2 unicode object 'left' and 'right' and a char object 'char'.
Indeed char is initialized with line 2797 of the function _OnChar(self, event) of MaskedEditMixin class
    char = char(key) # key is int

I solve this problem by replacing the line 4790 (newtext = left + char + right) by these 3 lines
    if type(char) is UnicodeType:
        char = char.decode("iso-8859-1")
    newtext = left + char + right

Is-it the good solution and is this problem solved in the new release?

Mignon Laurent wrote:

I solve this problem by replacing the line 4790 (newtext = left + char + right) by these 3 lines
    if type(char) is UnicodeType:
        char = char.decode("iso-8859-1")
    newtext = left + char + right

Is-it the good solution and is this problem solved in the new release?

I think so. Try it out and see.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!