"""
if isinstance(f, str):
- cm: contextlib.AbstractContextManager = open(f, "rt", encoding="utf-8")
+ cm: contextlib.AbstractContextManager = open(f, encoding="utf-8")
else:
cm = contextlib.nullcontext(f)
with cm as f:
nameservers = []
if isinstance(f, str):
try:
- cm: contextlib.AbstractContextManager = open(f, "rt", encoding="utf-8")
+ cm: contextlib.AbstractContextManager = open(f, encoding="utf-8")
except OSError:
# /etc/resolv.conf doesn't exist, can't be read, etc.
raise NoResolverConfiguration(f"cannot open {f}")
if isinstance(f, str):
if filename is None:
filename = f
- cm: contextlib.AbstractContextManager = open(f, "rt", encoding="utf-8")
+ cm: contextlib.AbstractContextManager = open(f, encoding="utf-8")
else:
cm = contextlib.nullcontext(f)
with cm as f:
self.default_ttl_known,
)
)
- self.current_file = open(filename, "rt", encoding="utf-8")
+ self.current_file = open(filename, encoding="utf-8")
self.tok = dns.tokenizer.Tokenizer(self.current_file, filename)
self.current_origin = new_origin
elif c == "$GENERATE":
def test_svcb_spec_test_vectors(self):
text_file = here("svcb_test_vectors.text")
text_tokenizer = Tokenizer(
- open(text_file, "rt", encoding="utf-8"), filename=text_file
+ open(text_file, encoding="utf-8"), filename=text_file
)
generic_file = here("svcb_test_vectors.generic")
generic_tokenizer = Tokenizer(
- open(generic_file, "rt", encoding="utf-8"), filename=generic_file
+ open(generic_file, encoding="utf-8"), filename=generic_file
)
while True:
def compare_files(test_name, a_name, b_name):
- with open(a_name, "rt", encoding="utf-8") as a:
- with open(b_name, "rt", encoding="utf-8") as b:
+ with open(a_name, encoding="utf-8") as a:
+ with open(b_name, encoding="utf-8") as b:
differences = list(difflib.unified_diff(a.readlines(), b.readlines()))
if len(differences) == 0:
return True