jfernandz / pyst2

A fork of the famous python pyst library for Asterisk.
138 stars 105 forks source link

string.encode bug #30

Open ghost opened 8 years ago

ghost commented 8 years ago

Archive: agi.py Bug Python 3 at Line: 128 return ''.join(['"', string.encode('utf8', 'ignore'), '"'])

Correction: return ''.join(['"', string.encode('ascii', 'ignore').decode('ascii'), '"'])

ghost commented 8 years ago

I had trouble with this, too. In fact, I just ended up with

def _quote(self, string):
    joined = '"' + string + '"'
    return joined`

And it appears to work OK.

This is also being discussed at https://github.com/rdegges/pyst2/issues/19 - would you mind adding to that too? The more the better!

mjmunger commented 6 years ago

I have been battling this for nearly (wasted) three hours now.

Neither the correction above works in 3.6.1, nor does the existing code (master).

Just returning the string before the join statement fixes the issue.

I realize there are some other considerations, but we really need to make a decision on the best implementation from the PRs becuase others will waste hours on it as well.