Issue #73 resolved

Calling str() on a keyboard event can cause UnicodeEncodeError on python3.

illume
created an issue

== Dávid Gábor Bodor, 2011-07-24 02:57:28 -0700

{{{ Using python3, str(event) raises UnicodeEncodeError, if event.unicode cannot be represented in ASCII.

(By extension, print(event) and repr(event) behaves the same way, since those call str(event).)

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) }}}


== Dávid Gábor Bodor, 2011-07-24 03:00:30 -0700

{{{ Created attachment 47 Fixes bug 73.

Fixes the bug.

Changes the unicode -> bytes conversion to use utf-8 instead of ascii as encoding. }}}


Attachments: [[http://www.pygame.org/old_bug_attachments/47/print_event.patch| print_event.patch]]

== Dávid Gábor Bodor, 2011-07-24 03:04:12 -0700

{{{ Note that I already posted a fix on the mailing list before discovering the bugtracker. Sorry for duplication the information, I hope it won't cause too much trouble. }}}


Comments (0)

  1. Log in to comment