Use os.fspath on Path (#15530)

### Description
<!-- Describe your changes. -->

Use os.fspath instead of str() on a path object. 

### Motivation and Context

I learned today that os.fspath is the right way to go:
https://github.com/charliermarsh/ruff/issues/3675#issuecomment-1494975508
This commit is contained in:
Justin Chu 2023-04-17 16:59:40 -07:00 committed by GitHub
parent a30b57da6e
commit 9d26f8f4fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -359,11 +359,8 @@ class InferenceSession(Session):
"""
super().__init__()
if isinstance(path_or_bytes, str):
self._model_path = path_or_bytes
self._model_bytes = None
elif isinstance(path_or_bytes, os.PathLike):
self._model_path = str(path_or_bytes)
if isinstance(path_or_bytes, (str, os.PathLike)):
self._model_path = os.fspath(path_or_bytes)
self._model_bytes = None
elif isinstance(path_or_bytes, bytes):
self._model_path = None