mackup icon indicating copy to clipboard operation
mackup copied to clipboard

UnicodeEncode error when calling mackup backup

Open andy9775 opened this issue 10 years ago • 11 comments

I'm trying to call mackup backup and I get the following error:

File "/usr/local/Cellar/mackup/0.8.11/libexec/bin/mackup", line 9, in <module>
    load_entry_point('mackup==0.8.11', 'console_scripts', 'mackup')()
  File "/usr/local/Cellar/mackup/0.8.11/libexec/lib/python2.7/site-packages/mackup/main.py", line 65, in main
    app_db = ApplicationsDatabase()
  File "/usr/local/Cellar/mackup/0.8.11/libexec/lib/python2.7/site-packages/mackup/appsdb.py", line 34, in __init__
    if config.read(config_file):
  File "/Library/Python/2.7/site-packages/configparser.py", line 709, in read
    self._read(fp, filename)
  File "/Library/Python/2.7/site-packages/configparser.py", line 1124, in _read
    optname = self.optionxform(optname.rstrip())
UnicodeEncodeError: 'ascii' codec can't encode character u'\xdc' in position 28: ordinal not in range(128)

I installed mackup via brew and I am running python 2.7.11. This error also came up with python 2.6

andy9775 avatar Dec 14 '15 20:12 andy9775

Yeah, I get this on python 3.5 too, installed mackup via pip. For me however, it work via homebrew. Hmm.

danmackinlay avatar Mar 04 '16 16:03 danmackinlay

To be clear, the error in python3.5 is different:

Traceback` (most recent call last):
  File "/usr/local/bin/mackup", line 9, in <module>
    load_entry_point('mackup==0.8.12', 'console_scripts', 'mackup')()
  File "/Users/dan/Source/mackup/mackup/main.py", line 64, in main
    mckp = Mackup()
  File "/Users/dan/Source/mackup/mackup/mackup.py", line 24, in __init__
    self._config = config.Config()
  File "/Users/dan/Source/mackup/mackup/config.py", line 52, in __init__
    self._path = self._parse_path()
  File "/Users/dan/Source/mackup/mackup/config.py", line 223, in _parse_path
    if sys.version_info[0] < 3:
AttributeError: 'str' object has no attribute 'decode'

danmackinlay avatar Mar 04 '16 17:03 danmackinlay

In python2.7 the error is thrown when parsing applications/ubersicht.cfg where the line Library/Application Support/Übersicht/widgets has a non-ascii character.

danmackinlay avatar Mar 04 '16 17:03 danmackinlay

I have this error also:

Traceback (most recent call last):
  File "/usr/bin/mackup", line 9, in <module>
    load_entry_point('mackup==0.8.12', 'console_scripts', 'mackup')()
  File "/usr/lib/python3.5/site-packages/mackup/main.py", line 64, in main
    mckp = Mackup()
  File "/usr/lib/python3.5/site-packages/mackup/mackup.py", line 24, in __init__
    self._config = config.Config()
  File "/usr/lib/python3.5/site-packages/mackup/config.py", line 52, in __init__
    self._path = self._parse_path()
  File "/usr/lib/python3.5/site-packages/mackup/config.py", line 225, in _parse_path
    path = path.decode("utf-8")
AttributeError: 'str' object has no attribute 'decode'

kilbyjmichael avatar Mar 07 '16 05:03 kilbyjmichael

me too

$ mackup backup
Traceback (most recent call last):
  File "/usr/local/bin/mackup", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/mackup/main.py", line 64, in main
    mckp = Mackup()
  File "/usr/local/lib/python3.5/dist-packages/mackup/mackup.py", line 24, in __init__
    self._config = config.Config()
  File "/usr/local/lib/python3.5/dist-packages/mackup/config.py", line 52, in __init__
    self._path = self._parse_path()
  File "/usr/local/lib/python3.5/dist-packages/mackup/config.py", line 225, in _parse_path
    path = path.decode("utf-8")
AttributeError: 'str' object has no attribute 'decode'

jujes avatar Apr 24 '16 22:04 jujes

any news on this same thing ubuntu 16.04 installed via pip Python 2.7.11+

mackup backup                                                                                                                                                             
Traceback (most recent call last):
  File "/usr/local/bin/mackup", line 11, in <module>
   sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/mackup/main.py", line 65, in main
    app_db = ApplicationsDatabase()
  File "/usr/local/lib/python2.7/dist-packages/mackup/appsdb.py", line 34, in __init__
    if config.read(config_file):
  File "/usr/local/lib/python2.7/dist-packages/configparser.py", line 709, in read
    self._read(fp, filename)
  File "/usr/local/lib/python2.7/dist-packages/configparser.py", line 1124, in _read
    optname = self.optionxform(optname.rstrip())
 UnicodeEncodeError: 'ascii' codec can't encode character u'\xdc' in position 28: ordinal not in    range(128)

ibeex avatar Jun 21 '16 14:06 ibeex

Yep. +1 on this for me as well making mackup a scary proposition right now. Not sure what to do about it. LOL. I feel like my configs are now hostages.

petergi avatar Sep 12 '16 15:09 petergi

Ok, so I managed to work around it. I uninstalled mackup with Brew. Then used pip3 to install it. NOT pip (same error if using pip). So I dunno... your mileage WILL vary. Good luck.

petergi avatar Sep 12 '16 18:09 petergi

In /usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py, I changed this line optname = self.optionxform(optname.rstrip()) to optname = self.optionxform(optname.encode('utf-8').rstrip()) and the problem is solved.

jinkunw avatar Sep 14 '16 21:09 jinkunw

I solved this by removing the utf-8 decoding of the path in mackup/config.py

<delete>
224: else:
225:     path = path.decode("utf-8")
</delete>

ooystein avatar Apr 29 '17 22:04 ooystein

Had this problem on Linux after installing using pip. No problems if installed using pip3

IgorKrupenja avatar Jan 26 '19 23:01 IgorKrupenja