<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -5,6 +5,7 @@ import string
 from django import forms
 from django.db import models
 from django.conf import settings
+from django.utils.encoding import smart_str
 
 
 USE_CPICKLE = getattr(settings, 'USE_CPICKLE', False)
@@ -92,19 +93,9 @@ class PickleField(models.TextField):
 
         # Tries to convert unicode objects to string, cause loads pickle from
         # unicode excepts ugly ``KeyError: '\x00'``.
-        #
-        # If not possible return this value, cause it's not pickled yet.
-        if isinstance(value, unicode):
-            try:
-                str_value = str(value)
-            except UnicodeEncodeError:
-                return value
-        else:
-            str_value = value
-
         try:
-            return pickle.loads(str_value)
+            return pickle.loads(smart_str(value))
+        # If pickle could not loads from string it's means that it's Python
+        # string saved to PickleField.
         except ValueError:
-            # If pickle could not loads from string it's means that it's Python
-            # string saved to PickleField.
             return value</diff>
      <filename>django_fields/fields.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>13ced586be3a7cac965579422e46707562732370</id>
    </parent>
  </parents>
  <author>
    <name>Igor Davydenko</name>
    <email>playpauseandstop@gmail.com</email>
  </author>
  <url>http://github.com/svetlyak40wt/django-fields/commit/ef7b37445c5652ae2bd40e237f31b238250d839d</url>
  <id>ef7b37445c5652ae2bd40e237f31b238250d839d</id>
  <committed-date>2009-02-16T21:19:48-08:00</committed-date>
  <authored-date>2009-02-16T16:31:29-08:00</authored-date>
  <message>Simplifies loading pickled data via ``django.utils.encoding.smart_str`` function.

Signed-off-by: Alexander Artemenko &lt;svetlyak.40wt@gmail.com&gt;</message>
  <tree>b301f97c9f8d3bea8e20c0159ecafc63c3ed505e</tree>
  <committer>
    <name>Alexander Artemenko</name>
    <email>svetlyak.40wt@gmail.com</email>
  </committer>
</commit>
