google/adb-sync

adb-sync fails with "encode() argument 1 must be string, not None" on Ubuntu 16.04

cirosantilli opened this issue · 1 comments

adb-sync -R /data/data/com.my.app .

outcome:

Traceback (most recent call last):
  File "/home/ciro/bin/adb-sync", line 774, in <module>
    main(*sys.argv)
  File "/home/ciro/bin/adb-sync", line 695, in main
    localpatterns = [x.encode(args_encoding) for x in args.source]
TypeError: encode() argument 1 must be string, not None

This happens because locale.getdefaultlocale()[1] is None.

Workaround: patch it with:

  args_encoding = locale.getdefaultlocale()[1] or 'utf-8'

but I'm not sure this is correct. But it worked for me.

Same also happens on a minimal test.py:

import locale
print locale.getdefaultlocale()

env is:

 'LANG': 'en_US:en',
 'LANGUAGE': 'en_US:en',
 'LC_ADDRESS': 'en_US.UTF-8',                                                        
 'LC_ALL': 'C',                                           
 'LC_COLLATE': 'C',          
 'LC_CTYPE': 'en_US.UTF-8',           
 'LC_IDENTIFICATION': 'en_US.UTF-8',
 'LC_MEASUREMENT': 'en_US.UTF-8',                         
 'LC_MESSAGES': 'en_US.UTF-8',   
 'LC_MONETARY': 'en_US.UTF-8',
 'LC_NAME': 'en_US.UTF-8',                                      
 'LC_NUMERIC': 'en_US.UTF-8',
 'LC_PAPER': 'en_US.UTF-8',
 'LC_TELEPHONE': 'en_US.UTF-8',
 'LC_TIME': 'en_US.UTF-8',

Oh, just fixed that actually while porting to Python3 + type annotations. Thanks for reporting though!