Use assertEqual rather than assertEquals as the latter is deprecated.
Fix unclosed file ResourceWarnings.
Use for loop instead of map when not iterating.
Check for bytes rather than str.
Use bytes literals instead of string literals.
Use six.moves.
Apply libmodernize.fixes.fix_dict.

(Exclude dulwich.objects)
Use six.byte2int, .indexbytes, and .iterbytes.
Fix PackBasedObjectStore.packs.