diff options
| author | Donny Winston <dwinston@alum.mit.edu> | 2020-05-26 13:02:47 -0400 |
|---|---|---|
| committer | Donny Winston <dwinston@alum.mit.edu> | 2020-05-26 13:02:47 -0400 |
| commit | b5fa8ec78ec6eba1df4530588c3568a8710b9cad (patch) | |
| tree | f51833d40f62351c8cc10d438e52ecc80c4604e3 | |
| parent | c0a87cf94adf0be83936fb1a6a1b57f3c62d0afe (diff) | |
| download | rdflib-b5fa8ec78ec6eba1df4530588c3568a8710b9cad.tar.gz | |
prefer specific LBYL vs less-specific EAFP
| -rw-r--r-- | rdflib/graph.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/rdflib/graph.py b/rdflib/graph.py index 2a4d7c01..145224b8 100644 --- a/rdflib/graph.py +++ b/rdflib/graph.py @@ -1072,10 +1072,10 @@ class Graph(Node): format = source.content_type assumed_xml = False if format is None: - try: + if (hasattr(source, "file") + and getattr(source.file, "name", None) + and isinstance(source.file.name, str)): format = rdflib.util.guess_format(source.file.name) - except (AttributeError, TypeError): - pass if format is None: format = "application/rdf+xml" assumed_xml = True |
