pyst2 icon indicating copy to clipboard operation
pyst2 copied to clipboard

string.encode bug

Open ghost opened this issue 9 years ago • 2 comments

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 avatar Sep 12 '16 18:09 ghost

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!

ghost avatar Nov 02 '16 21:11 ghost

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.

mjmunger avatar Jun 01 '18 09:06 mjmunger