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 #17

Closed
honi opened this issue Sep 27, 2011 · 8 comments
Closed

UnicodeDecodeError #17

honi opened this issue Sep 27, 2011 · 8 comments
Labels

Comments

@honi
Copy link

honi commented Sep 27, 2011

I think I've found another bug. I have a TextField in a model, and in the admin site, when I input a latin character, for example: á, after I submit the change_form and try to edit that object I get this error.

Here's the traceback:

Django Version: 1.3
Python Version: 2.6.1

Traceback:
File "/Users/jonito/mingus/proyectos/galerias-belgrano/bootstrap/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response

  1.             response = middleware_method(request, response)
    
    File "/Users/jonito/mingus/proyectos/galerias-belgrano/bootstrap/src/django-htmlmin/htmlmin/middleware.py" in process_response
  2.         response.content = html_minify(response.content)
    
    File "/Users/jonito/mingus/proyectos/galerias-belgrano/bootstrap/src/django-htmlmin/htmlmin/minify.py" in html_minify
  3.         html_code = html_code.replace(script, TAGS_PATTERN % (tag, index))
    

Exception Type: UnicodeDecodeError at /admin/chunks/chunk/2/
Exception Value: ('ascii', '<textarea id="id_content" rows="10" cols="40" name="content" class="vLargeTextField">Lunes a S\xc3\xa1bados de 9 a 20hs.</textarea>', 94, 95, 'ordinal not in range(128)')

@gilsondev
Copy link

Used in smart_unicode __unicode__ ? Will probably be it.

The data can come in ASCII, and can not convert to unicode.

@honi
Copy link
Author

honi commented Sep 28, 2011

I'm sorry, I didn't understand you completely.

This also happens for any <textarea> content. For example, you have a form with a field rendered as a textarea. If you submit the form with a latin character in the textarea, but the form doesn't validate, when the form is rendered again showing the errors, and where normally bounded fields show their values, this error happens.

@fsouza
Copy link
Contributor

fsouza commented Sep 28, 2011

Sorry for the delay, this week is a little hard, I'll take a deep look in the weekend :)

Thanks in advance for reporting.

@marcusalmeida
Copy link

Like said, the data come in ASCII and when try to replace "script" in html_code not convert to unicode.
Could we use "string.unicode('utf-8')" in line 20 in minify.py? Like this?
html_code = html_code.replace(script.decode('utf-8'), TAGS_PATTERN %(tag, index))

Is there any problem with it ?

@fsouza
Copy link
Contributor

fsouza commented Oct 7, 2011

Hi @marcusalmeida, I'll fix it today or this weekend (in the worst case).

Sorry for this long delay.

@fsouza fsouza closed this as completed in 41442f1 Oct 8, 2011
@fsouza
Copy link
Contributor

fsouza commented Oct 8, 2011

Just fixed it and released 0.5 version, please upgrade.

Thank you for reporting.

@marcusalmeida
Copy link

Nice. I'll upgrade.

@honi
Copy link
Author

honi commented Oct 11, 2011

Excellent! Thanks

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

No branches or pull requests

4 participants