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

mapit_import reports it couldn't find a name field when errors occur reading the name field #168

Open
stevenday opened this issue Mar 2, 2015 · 0 comments

Comments

@stevenday
Copy link
Contributor

This section: https://github.com/mysociety/mapit/blob/master/mapit/management/commands/mapit_import.py#L217-L230 of the mapit_import command tries to extract the name of a feature from the supplied data file, and prints a helpful error if it can't find a name under the field name you specified. Later on, it then tries to decode the name using the encoding you specified.

However, because the Django GDAL api uses force_text on the return value of fields, decoding errors can happen as soon as we read it. Right now, in the above code the first try/except catches them and so reports the wrong message to the user.

I'll take a stab at fixing this, this is just to remind me what the problem is.

stevenday pushed a commit that referenced this issue Mar 3, 2015
This changes the logic for extract and decoding the name from a
feature so that Exceptions are caught more selectively and the right
errors are reported to the user.

Previously, a UnicodeDecodeError could occur when the name field
was read (because internally, the GDAL api uses force_text on
the output) and the code would catch it but instead report that the
name field didn't exist. This was confusing on files with encoding
errors.

Closes #168
stevenday pushed a commit that referenced this issue Mar 3, 2015
This changes the logic for extract and decoding the name from a
feature so that Exceptions are caught more selectively and the right
errors are reported to the user.

Previously, a UnicodeDecodeError could occur when the name field
was read (because internally, the GDAL api uses force_text on
the output) and the code would catch it but instead report that the
name field didn't exist. This was confusing on files with encoding
errors.

Closes #168
stevenday pushed a commit that referenced this issue Mar 4, 2015
This changes the logic for extracting and decoding the name from a
feature so that Exceptions are caught more selectively and the right
errors are reported to the user.

Previously, a UnicodeDecodeError could occur when the name field
was read (because internally, the GDAL api uses force_text on
the output) and the code would catch it but instead report that the
name field didn't exist. This was confusing on files with encoding
errors.

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

Successfully merging a pull request may close this issue.

1 participant