core: replace UTF8_CODEC with encodings.utf_8.encode() function.

pull/607/head
David Wilson 5 years ago
parent 1305420aa5
commit dfefc4c05c

@ -37,6 +37,7 @@ bootstrap implementation sent to every new slave context.
import binascii
import collections
import encodings.latin_1
import encodings.utf_8
import errno
import fcntl
import itertools
@ -102,10 +103,9 @@ LOG = logging.getLogger('mitogen')
IOLOG = logging.getLogger('mitogen.io')
IOLOG.setLevel(logging.INFO)
LATIN1_CODEC = encodings.latin_1.Codec()
# str.encode() may take import lock. Deadlock possible if broker calls
# .encode() on behalf of thread currently waiting for module.
UTF8_CODEC = encodings.latin_1.Codec()
LATIN1_CODEC = encodings.latin_1.Codec()
_v = False
_vv = False
@ -288,7 +288,7 @@ class Kwargs(dict):
def __init__(self, dct):
for k, v in dct.iteritems():
if type(k) is unicode:
k, _ = UTF8_CODEC.encode(k)
k, _ = encodings.utf_8.encode(k)
self[k] = v
def __repr__(self):
@ -782,7 +782,7 @@ class Message(object):
"""
Syntax helper to construct a dead message.
"""
kwargs['data'], _ = UTF8_CODEC.encode(reason or u'')
kwargs['data'], _ = encodings.utf_8.encode(reason or u'')
return cls(reply_to=IS_DEAD, **kwargs)
@classmethod
@ -1381,7 +1381,7 @@ class Importer(object):
if mod.__package__ and not PY3:
# 2.x requires __package__ to be exactly a string.
mod.__package__, _ = UTF8_CODEC.encode(mod.__package__)
mod.__package__, _ = encodings.utf_8.encode(mod.__package__)
source = self.get_source(fullname)
try:

Loading…
Cancel
Save