Open ghost opened 8 years ago
If you do:
config['foo']['file'] = some_bytestring # like we do in beet in various places (likely in the tests)
and then attempt
file = config['foo']['file'].as_filename()
then it'll blow up right here https://github.com/beetbox/beets/blob/master/beets/util/confit.py#L1350
Got it. In those cases, it's probably best to change the tests—because, in the real world, those values with be Unicode strings when they come from config files. (And we'd like to test conditions that resemble the real world.)
ok, so that's back to the age old question of converting bytestring filenames to utf-8. come up with a name for the utility function yet? :)
Right; good point. Let's call it unicode_path
, I suppose. On Python 3, it can use surrogateescape
; on Python 2, I suppose it should just use strict
errors.
Can you elaborate a little bit? Where exactly is this needed, and why (vs. just wrapping the lookup with
bytestring_path()
)?