Force quoted string to ascii

If setting variables to non-ascii values (such as reading data from a database) your script will fail due to UnicodeEncodeError.
My forcing the encoding of the string at the 'quote' to ascii and ignoring non-ascii chars, we are able to prevent abnormal script exits due to quoted string chars.
master
TuxPowered 2015-11-14 03:00:29 -08:00
parent debdd61443
commit cef87f4241
1 changed files with 1 additions and 1 deletions

View File

@ -113,7 +113,7 @@ class AGI:
sys.stderr.write('\n')
def _quote(self, string):
return ''.join(['"', str(string), '"'])
return ''.join(['"', string.encode('ascii', 'ignore'), '"'])
def _handle_sighup(self, signum, frame):
"""Handle the SIGHUP signal"""