-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes Python 3 compatibility issue. #515
Conversation
Codecov Report
@@ Coverage Diff @@
## master #515 +/- ##
==========================================
- Coverage 90.25% 90.17% -0.09%
==========================================
Files 24 24
Lines 4004 4009 +5
==========================================
+ Hits 3614 3615 +1
- Misses 390 394 +4
Continue to review full report at Codecov.
|
babel/dates.py
Outdated
return self.pattern | ||
|
||
def __str__(self): | ||
self.__unicode__().encode('utf-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement is missing its return
statement.
babel/dates.py
Outdated
@@ -1215,8 +1214,16 @@ def __init__(self, pattern, format): | |||
def __repr__(self): | |||
return '<%s %r>' % (type(self).__name__, self.pattern) | |||
|
|||
def __unicode__(self): | |||
return self.pattern | |||
if PY2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I'd be more comfortable if the PY2 code lived within the functions instead of the class definition changing depending on interpreter version:
def __unicode__(self):
return self.pattern
def __str__(self):
pat = self.pattern
if PY2:
pat = pat.encode('utf-8')
return pat
(thanks to @akx).
Cf. issue #514