def fix_win_sys_argv(encoding):
 global _SYS_ARGV_PROCESSED
 if _SYS_ARGV_PROCESSED:
  return False
 from ctypes import byref, c_int, POINTER, windll, WINFUNCTYPE
 from ctypes.wintypes import LPCWSTR, LPWSTR
 GetCommandLineW = WINFUNCTYPE(LPWSTR)(('GetCommandLineW', windll.kernel32))
 CommandLineToArgvW = WINFUNCTYPE(POINTER(LPWSTR), LPCWSTR, POINTER(c_int))(('CommandLineToArgvW', windll.shell32))
 argc = c_int(0)
 argv_unicode = CommandLineToArgvW(GetCommandLineW(), byref(argc))
 argv = [argv_unicode[i].encode(encoding, 'replace') for i in xrange(0, argc.value)]
 if (not hasattr(sys, 'frozen')):
  argv = argv[1:]
  while (len(argv) > 0):
   arg = argv[0]
   if ((not arg.startswith(u'-')) or (arg == u'-')):
    break
   argv = argv[1:]
   if (arg == u'-m'):
    break
   if (arg == u'-c'):
    argv[0] = u'-c'
    break
 sys.argv = argv
 _SYS_ARGV_PROCESSED = True
 return True

def fix_win_sys_argv ( encoding ) : global _SYS_ARGV_PROCESSED if _SYS_ARGV_PROCESSED : return False from ctypes import byref , c_int , POINTER , windll , WINFUNCTYPE from ctypes . wintypes import LPCWSTR , LPWSTR GetCommandLineW = WINFUNCTYPE ( LPWSTR ) ( ( 'GetCommandLineW' , windll . kernel32 ) ) CommandLineToArgvW = WINFUNCTYPE ( POINTER ( LPWSTR ) , LPCWSTR , POINTER ( c_int ) ) ( ( 'CommandLineToArgvW' , windll . shell32 ) ) argc = c_int ( 0 ) argv_unicode = CommandLineToArgvW ( GetCommandLineW ( ) , byref ( argc ) ) argv = [ argv_unicode [ i ] . encode ( encoding , 'replace' ) for i in xrange ( 0 , argc . value ) ] if ( not hasattr ( sys , 'frozen' ) ) : argv = argv [ 1 : ] while ( len ( argv ) > 0 ) : arg = argv [ 0 ] if ( ( not arg . startswith ( u'-' ) ) or ( arg == u'-' ) ) : break argv = argv [ 1 : ] if ( arg == u'-m' ) : break if ( arg == u'-c' ) : argv [ 0 ] = u'-c' break sys . argv = argv _SYS_ARGV_PROCESSED = True return True
converts sys .