bbangert/beaker

Error: 'ascii' codec can't encode character u'\xb7' in position 143: ordinal not in range(128)

gabrielhpugliese opened this issue · 2 comments

Hi,

I'm using beaker on production for a big website (10k+ concurrent users) for years.
One day, one of our developers received that error Error: 'ascii' codec can't encode character u'\xb7' in position 143: ordinal not in range(128) and I went down to debug what's happening. I could finally go to the correct line of error:

formated_key = (self.namespace + '_' + key).replace(' ', '\302\267')

I can continue my debug on our part to see why only after years it's happening now and stuff, but I just have a question: is there any special reason for replacing spaces with a unicode middle dot (·)? I've put another string for replacement, like 'HELLO', without unicode stuff, it worked well on the development process.

amol- commented

It got introduced in 48a6da2

It looks to me that it got just used a really uncommon character to avoid colliding with other keys the user might have created.

I think that the proper solution would be to raise an error if the key contains a space instead of trying to automatically solve it. Any string you might use can actually collide.

Have you been able to find the origin of the problem? What was triggering the issue on your side?

I don't remember it well, but it was about some space in urls I think. I can check it again if it's the case. Other devs complained about it as well.