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 UnicodeDecodeError in annotate_excpetion #564

Conversation

hendrikmuhs
Copy link
Contributor

Hi,

this fixes a somewhat special problem: We are using lua scripts in redis in combination with pipelining and msgpack (using python 2.x).

In case of an error redis-py tries to build a proper error message using the annotate_exception method. When building the message it converts everything to unicode. The problem: This can fail as one or more parts might not be proper unicode. In our case this is due to using msgpack. That means that building the exception causes an exception (UnicodeEncodeError), hiding the original redis error.

The change I propose is to relax the unicode conversion by using a safe approach to convert the string. That fixes the UnicodeEncodeError which in turn gives me the real error message and the right exception (ResponseError).

Please have a look at the unit test, which shall document it better than my explanation above.

I tested both python2 and python3 (as you will see, there is basically no change for python3)

Hendrik

andymccurdy added a commit that referenced this pull request Dec 5, 2014
…exception-handling

Fix UnicodeDecodeError in annotate_excpetion
@andymccurdy andymccurdy merged commit 38b19cd into redis:master Dec 5, 2014
@andymccurdy
Copy link
Contributor

Thanks! Merged this.

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.

2 participants