Skip to content
Myr

Store unicode strings properly in exceptions

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 8ed2573 · Browse files · 2 files+12 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+12 added−3 removed

  • other:+12 added−3 removed

2 files+12 added−3 removed

modified:click/exceptions.py+10 added-3 removed
7 unmodified lines
8 #: The exit code for this exception9 exit_code = 11011 def __init__(self, message):12 ctor_msg = message13 if PY2:13 if message is not None:14 message = message.encode('utf-8')15 Exception.__init__(self, message)14 if ctor_msg is not None:15 ctor_msg = ctor_msg.encode('utf-8')16 Exception.__init__(self, ctor_msg)17 self.message = message1819 def format_message(self):20 return self.message2122 def __unicode__(self):23 return self.message2425 def __str__(self):26 return self.message.encode('utf-8')2728 def show(self, file=None):29 if file is None:30 file = get_text_stderr()31 echo('Error: %s' % self.format_message(), file=file)
180 unmodified lines
modified:CHANGES+2 added
6 unmodified lines
7-----------89(upcoming release with new features, release date to be decided)1011- The exception objects now store unicode properly.1213Version 6.314-----------1516(bugfix release; unreleased)
314 unmodified lines