def setdefaultencoding(encoding):
 func = getattr(sys, 'setdefaultencoding', None)
 if (func is None):
  import gc
  import types
  for obj in gc.get_objects():
   if (isinstance(obj, types.BuiltinFunctionType) and (obj.__name__ == 'setdefaultencoding')):
    func = obj
    break
  if (func is None):
   raise RuntimeError('Could not find setdefaultencoding')
  sys.setdefaultencoding = func
 return func(encoding)

def setdefaultencoding ( encoding ) : func = getattr ( sys , 'setdefaultencoding' , None ) if ( func is None ) : import gc import types for obj in gc . get_objects ( ) : if ( isinstance ( obj , types . BuiltinFunctionType ) and ( obj . __name__ == 'setdefaultencoding' ) ) : func = obj break if ( func is None ) : raise RuntimeError ( 'Could not find setdefaultencoding' ) sys . setdefaultencoding = func return func ( encoding )
set the current default string encoding used by the unicode implementation .