Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import sys
if will_pass_encoding is None:
"""
By default,
if user has reloaded module "sys", we should pass defaultencoding to the remote side.
Because "reload(sys)" and "sys.setdefaultencoding(encoding)" are most probably related.
TODO(zhangyuncong):
We should have a further discussion about
whether we should pass the encoding by default or not.
"""
will_pass_encoding = hasattr(sys, 'setdefaultencoding')
if will_pass_encoding:
default_encoding = sys.getdefaultencoding()
logger.warn("pass defaultencoding %s to the remote side" % default_encoding)
def set_default_encoding():
import sys
reload(sys)
sys.setdefaultencoding(default_encoding)
# \0 makes sure this hook will run before user's
self.set_init_hook('\0set_sys_defaultencoding', set_default_encoding)