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

Remove the u prefix of unicode strings on error output #218

Closed
jmwri opened this issue Sep 27, 2016 · 7 comments
Closed

Remove the u prefix of unicode strings on error output #218

jmwri opened this issue Sep 27, 2016 · 7 comments

Comments

@jmwri
Copy link
Contributor

jmwri commented Sep 27, 2016

I use unicode everywhere within my project, and this affects the output of Voluptuous' exceptions.

required key not provided @ data[u'site_user_id']

Is it possible to remove the unicode prefix?

@tusharmakkar08
Copy link
Collaborator

Can you please share your schema? Since according to this test, it shouldn't be there at the first place.

@jmwri
Copy link
Contributor Author

jmwri commented Sep 27, 2016

Changing the test to the following is what I am doing:

schema = Schema({Required(u'q'): 1})

Notice the unicode dict key. From what I have seen it is best practice to ensure all strings are unicode strings, so I only use unicode literals in my project.

@tusharmakkar08
Copy link
Collaborator

Umm.. Ok. Can you create a PR corresponding to it? You will have to do modifications in schema_builder.py for supporting this feature.

@jmwri
Copy link
Contributor Author

jmwri commented Sep 27, 2016

I will investigate and ask if I need any help. Thanks :)!

@jmwri
Copy link
Contributor Author

jmwri commented Sep 27, 2016

Sorry @tusharmakkar08, would you be able to briefly explain the flow? I'm not really reading this too well.

@tusharmakkar08
Copy link
Collaborator

@jmwri : Ok.

Start from Line 147 where Schema class is defined which calls _compile in Line 219 and depending on the type of schema appropriate function is called. For your scenario, you can focus on self._compile_dict and self. _compile_object. These functions further call self. _compile_mapping at Line 239. Here we call as a closure validate_mapping in Line 262, where the final output is yielded. So you need to essentially make changes in self._compile_mapping function.

@jmwri
Copy link
Contributor Author

jmwri commented Sep 28, 2016

@tusharmakkar08 I have made changes to account for unicode Marker keys and plain text keys too. Are there any other types of keys?

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

No branches or pull requests

3 participants