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

avoid encoding problems when handling unicode strings from sqlite db #223

Closed
wants to merge 1 commit into from

Conversation

mir06
Copy link

@mir06 mir06 commented Oct 25, 2016

using python 2.X the the format strings must be marked as unicode, because sqlite delivers utf-8 strings

string = u'groß' 
"{}".format(string)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 3: ordinal not in range(128)
string = u'groß' 
u"{}".format(string)
u'gro\xdf'
u"{}".format(string).encode('utf-8')
'gro\xc3\x9f'

@coveralls
Copy link

coveralls commented Oct 25, 2016

Coverage Status

Coverage remained the same at 95.882% when pulling ecb4145 on mir06:sqlite-utf8 into a34f81b on django-dbbackup:master.

@ZuluPro
Copy link
Contributor

ZuluPro commented Nov 17, 2016

Hello @mir06
Sorry for my latency, I just see your PR,
After fix, I'll merge it soon.

@ZuluPro ZuluPro self-assigned this Nov 17, 2016
@ZuluPro ZuluPro added bug Bugs that need to get fixed. database db/sqlite labels Nov 17, 2016
@mir06
Copy link
Author

mir06 commented Nov 19, 2016

@ZuluPro don't worry, thanks for your package

@ZuluPro
Copy link
Contributor

ZuluPro commented Nov 21, 2016

Hello @mir06,

I can't accept your solution because it won't work with python 3.2,
And we want dbbackup to help devs to get out from this version :D

I fix it by put from __future__ import unicode_literals, simply...
And added a test about it.
You'll have this fix in 3.1.1, very soon.

Thanks for your work and do not hesitate to open an issue if it isn't resolved for you.

@ZuluPro ZuluPro closed this Nov 21, 2016
@mir06
Copy link
Author

mir06 commented Nov 21, 2016

@ZuluPro well, yes that's more elegant 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs that need to get fixed. db/sqlite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants