jborg/attic — pull request #149 by memorius (2014-12-14 06:48:02+00:00)
Title: Fix issue 106 - handle None as empty xattr value in setxattr

Fixes this: https://github.com/jborg/attic/issues/106

## Background:
I was hitting the above issue with attic on my MacOSX system, so I modified the ```setxattr``` code to see what it was failing on: turns out some other software on the system is setting the xattr ```lumberjack.log.archived``` with empty values. So it looks like xattrs are allowed to be empty, and it turns out attic can easily be updated to handle that, and to apply those empty values when extracting. (Rather than just to skip them, as in the workaround code someone else put on issue #106.) So I've made that change.

## This change:
```xattr``` attribute values can be empty. ```getxattr``` returns ```None``` for these,
so the dict from ```xattr.get_all``` can contain None values, and this is
stored in the archive data.
Handle these None values in setxattr: don't call ```os.fsencode``` because it
errors on None, and pass None and length 0 to the libc function.

I've chosen to handle None values, rather than change the archive data
to contain empty byte values, since we likely already have people out
there with archive data containing None.

I've tested this locally - it now restores the empty attribute values without error, and this roundtrips correctly when backed up again after extracting.