def push_char(self, char):
self.partial_char += char
try:
c = unicode(self.partial_char, self.encoding)
except UnicodeError, e:
if len(e.args) > 4 and \
e.args[4] == 'unexpected end of data':
pass
else:
# was: "raise". But it crashes pyrepl, and by extension the
# pypy currently running, in which we are e.g. in the middle
# of some debugging session. Argh. Instead just print an
# error message to stderr and continue running, for now.
self.partial_char = ''
sys.stderr.write('\n%s: %s\n' % (e.__class__.__name__, e))
else:
self.partial_char = ''
self.event_queue.push(c)
评论列表
文章目录