Fix several problems with filename handling #284
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
OpenSlide()andOpenSlide.detect_format()have failed to accept filename arguments formatted asbytesbecausestr(b'abc') == "b'abc'". In addition, filename arguments with invalid types (such asNone) have been stringified and passed to OpenSlide, rather than raising an exception during conversion; we even had tests for this (!).lowlevelhas always encoded filename arguments to UTF-8, but on non-Windows it should have used the Python filesystem encoding instead (usually UTF-8 but not always). On Windows, OpenSlide 4.0.0+ expects UTF-8 rather than arbitrary bytes. (OpenSlide < 4.0.0 expects the system codepage, which isn't very useful in practice because of its limited character set, so we ignore that case for now.)bytes, nor did they allowos.PathLikesubclasses which were notpathlib.Path(such aspathlib.PurePath).Accept
str,bytes, oros.PathLikefor all filename arguments, and properly convert them tobytesfor OpenSlide.In addition, allow
bytesin type hints for_utf8_parguments inlowlevel. The high-level API doesn't acceptbytesfor any of the affected functionality, butlowleveldoes, so encode that in the type signatures.