diff --git a/rdflib/namespace/__init__.py b/rdflib/namespace/__init__.py index d96c21f35..8455e2b63 100644 --- a/rdflib/namespace/__init__.py +++ b/rdflib/namespace/__init__.py @@ -508,7 +508,7 @@ def normalizeUri(self, rdfTerm: str) -> str: if namespace not in self.__strie: insert_strie(self.__strie, self.__trie, str(namespace)) namespace = URIRef(str(namespace)) - except: + except Exception: if isinstance(rdfTerm, Variable): return "?%s" % rdfTerm else: diff --git a/rdflib/plugins/parsers/notation3.py b/rdflib/plugins/parsers/notation3.py index 08798076a..2a64be24f 100755 --- a/rdflib/plugins/parsers/notation3.py +++ b/rdflib/plugins/parsers/notation3.py @@ -353,7 +353,7 @@ def becauseSubexpression(*args: Any, **kargs: Any) -> None: def unicodeExpand(m: Match) -> str: try: return chr(int(m.group(1), 16)) - except: + except Exception: raise Exception("Invalid unicode code point: " + m.group(1)) @@ -1711,7 +1711,7 @@ def _unicodeEscape( ) try: return i + n, reg.sub(unicodeExpand, "\\" + prefix + argstr[i : i + n]) - except: + except Exception: raise BadSyntax( self._thisDoc, startline, diff --git a/rdflib/plugins/parsers/trix.py b/rdflib/plugins/parsers/trix.py index 187c6d45d..8baaf5ca4 100644 --- a/rdflib/plugins/parsers/trix.py +++ b/rdflib/plugins/parsers/trix.py @@ -105,7 +105,7 @@ def startElementNS( try: self.lang = attrs.getValue((str(XMLNS), "lang")) - except: + except Exception: # language not required - ignore pass try: @@ -122,7 +122,7 @@ def startElementNS( self.datatype = None try: self.lang = attrs.getValue((str(XMLNS), "lang")) - except: + except Exception: # language not required - ignore pass diff --git a/rdflib/plugins/serializers/longturtle.py b/rdflib/plugins/serializers/longturtle.py index 263604fac..ac2febdcf 100644 --- a/rdflib/plugins/serializers/longturtle.py +++ b/rdflib/plugins/serializers/longturtle.py @@ -124,7 +124,7 @@ def getQName(self, uri, gen_prefix=True): try: parts = self.store.compute_qname(uri, generate=gen_prefix) - except: + except Exception: # is the uri a namespace in itself? pfx = self.store.store.prefix(uri) @@ -245,7 +245,7 @@ def isValidList(self, l_): try: if self.store.value(l_, RDF.first) is None: return False - except: + except Exception: return False while l_: if l_ != RDF.nil and len(list(self.store.predicate_objects(l_))) != 2: diff --git a/rdflib/plugins/serializers/rdfxml.py b/rdflib/plugins/serializers/rdfxml.py index e3d9ec777..c5acc74ad 100644 --- a/rdflib/plugins/serializers/rdfxml.py +++ b/rdflib/plugins/serializers/rdfxml.py @@ -253,7 +253,7 @@ def subject(self, subject: IdentifiedNode, depth: int = 1): try: # type error: Argument 1 to "qname" of "NamespaceManager" has incompatible type "Optional[Node]"; expected "str" self.nm.qname(type) # type: ignore[arg-type] - except: + except Exception: type = None element = type or RDFVOC.Description diff --git a/rdflib/plugins/serializers/turtle.py b/rdflib/plugins/serializers/turtle.py index ff4cd164f..ad1182474 100644 --- a/rdflib/plugins/serializers/turtle.py +++ b/rdflib/plugins/serializers/turtle.py @@ -273,7 +273,7 @@ def getQName(self, uri, gen_prefix=True): try: parts = self.store.compute_qname(uri, generate=gen_prefix) - except: + except Exception: # is the uri a namespace in itself? pfx = self.store.store.prefix(uri) @@ -397,7 +397,7 @@ def isValidList(self, l_): try: if self.store.value(l_, RDF.first) is None: return False - except: + except Exception: return False while l_: if l_ != RDF.nil and len(list(self.store.predicate_objects(l_))) != 2: diff --git a/rdflib/query.py b/rdflib/query.py index e9c189017..261ffde9a 100644 --- a/rdflib/query.py +++ b/rdflib/query.py @@ -409,7 +409,7 @@ def __eq__(self, other: Any) -> bool: return self.vars == other.vars and self.bindings == other.bindings else: return self.graph == other.graph - except: + except Exception: return False diff --git a/rdflib/tools/csv2rdf.py b/rdflib/tools/csv2rdf.py index 267483ed5..fe740356a 100644 --- a/rdflib/tools/csv2rdf.py +++ b/rdflib/tools/csv2rdf.py @@ -414,7 +414,7 @@ def convert(self, csvreader): "%d rows, %d triples, elapsed %.2fs.\n" % (rows, self.triples, time.time() - start) ) - except: + except Exception: sys.stderr.write("Error processing line: %d\n" % rows) raise diff --git a/rdflib/tools/rdf2dot.py b/rdflib/tools/rdf2dot.py index 1a33ee264..0ca1fa1e0 100644 --- a/rdflib/tools/rdf2dot.py +++ b/rdflib/tools/rdf2dot.py @@ -98,7 +98,7 @@ def label(x, g): return l_ try: return g.namespace_manager.compute_qname(x)[2] - except: + except Exception: return x def formatliteral(l, g): @@ -113,7 +113,7 @@ def qname(x, g): try: q = g.compute_qname(x) return q[0] + ":" + q[2] - except: + except Exception: return x def color(p): diff --git a/rdflib/tools/rdfs2dot.py b/rdflib/tools/rdfs2dot.py index 69ecfba58..4e639b48d 100644 --- a/rdflib/tools/rdfs2dot.py +++ b/rdflib/tools/rdfs2dot.py @@ -87,7 +87,7 @@ def label(xx, grf): if lbl is None: try: lbl = grf.namespace_manager.compute_qname(xx)[2] - except: + except Exception: pass # bnodes and some weird URIs cannot be split return lbl