Fixed _force_text_recursive typo by KostyaEsmukov · Pull Request #3908 · encode/django-rest-framework (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation6 Commits2 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Looks like a typo.
Steps to reproduce:
>>> from django.utils.translation import ugettext_lazy as _
>>> from rest_framework.exceptions import _force_text_recursive
>>> _force_text_recursive(_("fdsf"))
'fdsf'
>>> _force_text_recursive({'a': _("fdsf")})
{'a': <django.utils.functional.lazy.<locals>.__proxy__ object at 0x10ba73e80>}
Interesting, I'm wondering how this looked like before vs with this change.
Something like this.
>>> from rest_framework.exceptions import ValidationError
>>> from django.utils.translation import ugettext_lazy as _
Before:
>>> raise ValidationError({'__all__': _('Blah blah')})
Traceback (most recent call last):
File "<input>", line 1, in <module>
rest_framework.exceptions.ValidationError: {'__all__': <django.utils.functional.lazy.<locals>.__proxy__ object at 0x1052aad68>}
After:
>>> raise ValidationError({'__all__': _('Blah blah')})
Traceback (most recent call last):
File "<input>", line 1, in <module>
rest_framework.exceptions.ValidationError: {'__all__': 'Blah blah'}
I'm just wondering how or why this wasn't raised before. @xordoquy any ideas?
That's a somewhat minor side effect for the display.
Now that you mention it I think I'v already seen that and didn't paid much attention to it.
Note that in the end the lazy object will get translated anyway which is why I said it was minor.
xordoquy added this to the 3.3.4 Release milestone
Good catch, thanks for the PR !
xordoquy added a commit that referenced this pull request
Fixed _force_text_recursive typo
nazarewk pushed a commit to 10clouds/django-rest-framework that referenced this pull request
This was referenced
Mar 9, 2017