Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch long string path exists fail #58

Merged
merged 1 commit into from
Dec 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/ome_types/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,13 @@ def to_dict( # type: ignore
if tree is None:
from io import StringIO

_xml = xml if os.path.exists(xml) else StringIO(xml)
# determine if we're dealing with a raw XML string or a filepath
# very long XML strings will raise ValueError on Windows.
try:
_xml = xml if os.path.exists(xml) else StringIO(xml)
except ValueError:
_xml = StringIO(xml)

tree = ElementTree.parse(_xml) # type: ignore
aid = annotation["id"]
elt = tree.find(f".//{NS_OME}XMLAnnotation[@ID='{aid}']/{NS_OME}Value")
Expand Down