Skip to content
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

Fixed _force_text_recursive typo #3908

Merged
merged 2 commits into from
Feb 12, 2016
Merged

Fixed _force_text_recursive typo #3908

merged 2 commits into from
Feb 12, 2016

Conversation

KostyaEsmukov
Copy link
Contributor

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

@jpadilla
Copy link
Member

jpadilla commented Feb 9, 2016

Interesting, I'm wondering how this looked like before vs with this change.

@KostyaEsmukov
Copy link
Contributor Author

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

@jpadilla
Copy link
Member

I'm just wondering how or why this wasn't raised before. @xordoquy any ideas?

@xordoquy
Copy link
Collaborator

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.

@xordoquy
Copy link
Collaborator

Note that in the end the lazy object will get translated anyway which is why I said it was minor.

@xordoquy xordoquy added this to the 3.3.4 Release milestone Feb 12, 2016
@xordoquy
Copy link
Collaborator

Good catch, thanks for the PR !

@xordoquy xordoquy modified the milestones: 3.4.0 Release, 3.3.4 Release Feb 12, 2016
xordoquy added a commit that referenced this pull request Feb 12, 2016
@xordoquy xordoquy merged commit 3693e93 into encode:master Feb 12, 2016
nazarewk pushed a commit to 10clouds/django-rest-framework that referenced this pull request Apr 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants