Open sevein opened 5 years ago
Hi @sevein, was this addressed in https://github.com/artefactual-labs/mets-reader-writer/commit/3347a142e4bf3f6fdc5708b679061171b382b201? Can we close this or is there anything else to do?
Not sure what the testing plan is for all the Py3 issues but maybe we should start closing those that we consider "done" and report new ones when we test Py3 altogether.
I don't think this is fixed since path
is still unicode in Py3 and the original intention was to use a bytestring. But we may want to consider again whether this is an actual problem. @replaceafill, what do you think?
I don't think this is fixed since
path
is still unicode in Py3 and the original intention was to use a bytestring.
Sorry for answering your question with a question :blush: but do you think using a pathlib
object instead of strings might help with the splicing issue mentioned in the original comment? It might be a bigger change to the library and client code but sounds like the right approach to me.
What do you think the comment means exactly with "splicing"? 🤷
Oh, I assumed it meant path handling: joins, subpaths, base names, etc. which are a problem when you start mixing bytes and unicode.
So I guess pathlib embraces the melted unicode sandwich? :D
FWIW pathlib.Path
doesn't accept bytestrings in Python 3:
TypeError: argument should be a str object or an os.PathLike object returning str, not <class 'bytes'>
Expected behaviour
metsrw.FSEntry
prefers to store the binary representation of the filepath. I understood that's a design choice because of the following snippet in theFSEntry
constructor:In metsrw 0.3.0, the snippet above was refactored for better support of unicode input encoding (work done for https://github.com/artefactual/archivematica-storage-service/pull/438) - however the issue described here with Python 3 is still relevant.
Current behaviour In Python 3, metsrw uses
str
aka unicode - whereas in Python 2, it's usingbytes
aka binary. When changed to binary, tests don't pass mostly due to the lack of coercion.Steps to reproduce
FSEntry
wherepath
is bytes.FSEntry.path
Your environment (version of Archivematica, OS version, etc) metsrw (all versions seem affected)
For Artefactual use: Please make sure these steps are taken before moving this issue from Review to Verified in Waffle: