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

UnicodeDecodeError while constructing ParserError #177

Closed
allixsenos opened this issue Nov 10, 2014 · 3 comments
Closed

UnicodeDecodeError while constructing ParserError #177

allixsenos opened this issue Nov 10, 2014 · 3 comments

Comments

@allixsenos
Copy link

allixsenos commented Nov 10, 2014

Traceback (most recent call last):
  File "/Users/allixsenos/webs/hitlist/backend/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 114, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/allixsenos/webs/hitlist/backend/api/views.py", line 1627, in deals_list
    return deals_list_v3(request, api_version, *args, **kwargs)
  File "/Users/allixsenos/webs/hitlist/backend/api/timing.py", line 50, in _wrapper
    return f(*args, **kwargs)
  File "/Users/allixsenos/webs/hitlist/backend/venv/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/allixsenos/webs/hitlist/backend/venv/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/allixsenos/webs/hitlist/backend/venv/lib/python2.7/site-packages/rest_framework/views.py", line 400, in dispatch
    response = self.handle_exception(exc)
  File "/Users/allixsenos/webs/hitlist/backend/venv/lib/python2.7/site-packages/rest_framework/views.py", line 397, in dispatch
    response = handler(request, *args, **kwargs)
  File "/Users/allixsenos/webs/hitlist/backend/venv/lib/python2.7/site-packages/rest_framework/decorators.py", line 49, in handler
    return func(*args, **kwargs)
  File "/Users/allixsenos/webs/hitlist/backend/api/utils.py", line 293, in inner
    return func(request, *args, **kwargs)
  File "/Users/allixsenos/webs/hitlist/backend/api/views.py", line 1685, in deals_list_v3
    return deals_for_city_v3(request, api_version, city, flights)
  File "/Users/allixsenos/webs/hitlist/backend/api/views.py", line 1638, in deals_for_city_v3
    flights = filter_flights(request, flights)
  File "/Users/allixsenos/webs/hitlist/backend/api/utils.py", line 147, in filter_flights
    date_start = arrow.get(request.GET.get('date_start')) if request.GET.get('date_start') else None
  File "/Users/allixsenos/webs/hitlist/backend/venv/lib/python2.7/site-packages/arrow/api.py", line 23, in get
    return _factory.get(*args, **kwargs)
  File "/Users/allixsenos/webs/hitlist/backend/venv/lib/python2.7/site-packages/arrow/factory.py", line 156, in get
    dt = parser.DateTimeParser(locale).parse_iso(arg)
  File "/Users/allixsenos/webs/hitlist/backend/venv/lib/python2.7/site-packages/arrow/parser.py", line 104, in parse_iso
    return self._parse_multiformat(string, formats)
  File "/Users/allixsenos/webs/hitlist/backend/venv/lib/python2.7/site-packages/arrow/parser.py", line 245, in _parse_multiformat
    raise ParserError('Could not match input to any of {0} on \'{1}\''.format(formats, string))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

if the string passed to arrow.get() is a unicode string and parsing fails, it will not raise a ParserError but a UnicodeEncodeError

suggest either making the parsing message unicode, or not including the original string in the message

offending string is u'٢٠١٤-١٢-٠١' or u'\u0662\u0660\u0661\u0664-\u0661\u0662-\u0660\u0661'

@andrewelkins
Copy link
Contributor

It should be unicode.

@jadchaar
Copy link
Member

This seems to only be an issue with Python 2.7. I tried implementing the fix recommended in this StackOverflow post: https://stackoverflow.com/a/29430342/3820660, but our testing framework, Chai, does not seem to play well with the change.

We will have to keep investigating.

@jadchaar
Copy link
Member

jadchaar commented Nov 8, 2020

We will be dropping support for Python 2.7 in version 1.0.0, so I am going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants