[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Re: PATCH: fix printing of event in python3
A fixed patch file, this can be applied from the project root.
2011/7/24 Dávid Gábor Bodor <david.gabor.bodor@xxxxxxxxx>:
> The attached patch FIXES the bug described below.
>
> BUG description:
> Using python3, print(event) raises UnicodeEncodeError,
> if event.unicode cannot be represented in ASCII.
>
> Example:
> $ python3
>>>> import pygame
>>>> pygame.display.set_mode((640, 480))
>>>> while True:
> ... for event in pygame.event.get():
> ... print(event)
> [ user presses a key that cannot be represented in ASCII, like: őüöóúűáí ]
> UnicodeEncodeError: 'ascii' codec can't encode character '\xed' in position 13:
> ordinal not in range(128)
>
Index: src/event.c
===================================================================
--- src/event.c (revision 3193)
+++ src/event.c (working copy)
@@ -392,7 +392,7 @@
return NULL;
}
#if PY3
- encodedobj = PyUnicode_AsASCIIString (strobj);
+ encodedobj = PyUnicode_AsUTF8String (strobj);
Py_DECREF (strobj);
strobj = encodedobj;
encodedobj = NULL;