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

Fix get_db_prep_value() with Unicode values, Python 2 and 3 #44

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Fix get_db_prep_value() with Unicode values, Python 2 and 3 #44

wants to merge 3 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 31, 2014

Corrects issue where UUID value is a Unicode string for database lookup in UUIDField.get_db_prep_value(), compatible with Python 2 and 3.

Bryon Elston added 3 commits October 30, 2014 20:21
Corrects issue where UUID value is a Unicode string for database lookup in UUIDField.get_db_prep_value(), compatible with Python 2 and 3.
Whoops! This:

```
try:
    basestring
except NameError:
    basestring = str
```

Will raise an UnboundLocalError (subclass of NameError) and result in the same behavior as prior to this fix. Introduced another variable  to prevent this.
@LordGaav
Copy link

+1, just tested this and this fixes our issue.

I encountered a similar issue and could test it reliably using the sqlite testsuite and these lines at the end of test_hyphenated:

        obj = HyphenatedUUIDField.objects.get(uuid=unicode(obj.uuid))

        self.assertTrue(obj.uuid, uuid)
        self.assertTrue(obj.name, 'shoe')

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 this pull request may close these issues.

1 participant