Skip to content

Commit 267622b

Browse files
committed
style: use the official designation for utf-8
Yes, this is completely unimportant. Don't ask me why I bothered, I'm not really sure.
1 parent 498b148 commit 267622b

11 files changed

+16
-16
lines changed

coverage/annotate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def annotate_file(self, fr, analysis):
7373
else:
7474
dest_file = fr.filename + ",cover"
7575

76-
with open(dest_file, 'w', encoding='utf8') as dest:
76+
with open(dest_file, 'w', encoding='utf-8') as dest:
7777
i = 0
7878
j = 0
7979
covered = True

coverage/inorout.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def check_include_omit_etc(self, filename, frame):
432432

433433
# No point tracing a file we can't later write to SQLite.
434434
try:
435-
filename.encode("utf8")
435+
filename.encode("utf-8")
436436
except UnicodeEncodeError:
437437
return "non-encodable filename"
438438

coverage/misc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,15 @@ def __init__(self):
236236

237237
def update(self, v):
238238
"""Add `v` to the hash, recursively if needed."""
239-
self.hash.update(str(type(v)).encode("utf8"))
239+
self.hash.update(str(type(v)).encode("utf-8"))
240240
if isinstance(v, str):
241-
self.hash.update(v.encode('utf8'))
241+
self.hash.update(v.encode("utf-8"))
242242
elif isinstance(v, bytes):
243243
self.hash.update(v)
244244
elif v is None:
245245
pass
246246
elif isinstance(v, (int, float)):
247-
self.hash.update(str(v).encode("utf8"))
247+
self.hash.update(str(v).encode("utf-8"))
248248
elif isinstance(v, (tuple, list)):
249249
for e in v:
250250
self.update(e)

coverage/phystokens.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ def compile_unicode(source, filename, mode):
201201
202202
Python 2's compile() builtin has a stupid restriction: if the source string
203203
is Unicode, then it may not have a encoding declaration in it. Why not?
204-
Who knows! It also decodes to utf8, and then tries to interpret those utf8
205-
bytes according to the encoding declaration. Why? Who knows!
204+
Who knows! It also decodes to utf-8, and then tries to interpret those
205+
utf-8 bytes according to the encoding declaration. Why? Who knows!
206206
207207
This function neuters the coding declaration, and compiles it.
208208

coverage/plugin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,12 @@ def source(self):
359359
Returns a Unicode string.
360360
361361
The base implementation simply reads the `self.filename` file and
362-
decodes it as UTF8. Override this method if your file isn't readable
362+
decodes it as UTF-8. Override this method if your file isn't readable
363363
as a text file, or if you need other encoding support.
364364
365365
"""
366366
with open(self.filename, "rb") as f:
367-
return f.read().decode("utf8")
367+
return f.read().decode("utf-8")
368368

369369
def lines(self):
370370
"""Get the executable lines in this file.

coverage/sqldata.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def dumps(self):
349349
if self._debug.should("dataio"):
350350
self._debug.write(f"Dumping data from data file {self._filename!r}")
351351
with self._connect() as con:
352-
return b"z" + zlib.compress(con.dump().encode("utf8"))
352+
return b"z" + zlib.compress(con.dump().encode("utf-8"))
353353

354354
@contract(data="bytes")
355355
def loads(self, data):
@@ -373,7 +373,7 @@ def loads(self, data):
373373
raise CoverageException(
374374
f"Unrecognized serialization: {data[:40]!r} (head of {len(data)} bytes)"
375375
)
376-
script = zlib.decompress(data[1:]).decode("utf8")
376+
script = zlib.decompress(data[1:]).decode("utf-8")
377377
self._dbs[threading.get_ident()] = db = SqliteDb(self._filename, self._debug)
378378
with db:
379379
db.executescript(script)

igor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def do_zip_mods():
234234
""")
235235
# These encodings should match the list in tests/test_python.py
236236
details = [
237-
('utf8', 'ⓗⓔⓛⓛⓞ, ⓦⓞⓡⓛⓓ'),
237+
('utf-8', 'ⓗⓔⓛⓛⓞ, ⓦⓞⓡⓛⓓ'),
238238
('gb2312', '你好,世界'),
239239
('hebrew', 'שלום, עולם'),
240240
('shift_jis', 'こんにちは世界'),

tests/goldtest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def canonicalize_xml(xtext):
122122
for node in root.iter():
123123
node.attrib = dict(sorted(node.items()))
124124
xtext = xml.etree.ElementTree.tostring(root)
125-
return xtext.decode('utf8')
125+
return xtext.decode("utf-8")
126126

127127

128128
def contains(filename, *strlist):

tests/helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def make_file(filename, text="", bytes=b"", newline=None):
6969
text = textwrap.dedent(text)
7070
if newline:
7171
text = text.replace("\n", newline)
72-
data = text.encode('utf8')
72+
data = text.encode("utf-8")
7373

7474
# Make sure the directories are available.
7575
dirs, _ = os.path.split(filename)

tests/test_process.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ def test_fullcoverage(self):
759759
# Pypy passes locally, but fails in CI? Perhaps the version of macOS is
760760
# significant? https://foss.heptapod.net/pypy/pypy/-/issues/3074
761761
@pytest.mark.skipif(env.PYPY, reason="PyPy is unreliable with this test")
762-
# Jython as of 2.7.1rc3 won't compile a filename that isn't utf8.
762+
# Jython as of 2.7.1rc3 won't compile a filename that isn't utf-8.
763763
@pytest.mark.skipif(env.JYTHON, reason="Jython can't handle this test")
764764
def test_lang_c(self):
765765
# LANG=C forces getfilesystemencoding on Linux to 'ascii', which causes

tests/test_python.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class GetZipBytesTest(CoverageTest):
2121

2222
@pytest.mark.parametrize(
2323
"encoding",
24-
["utf8", "gb2312", "hebrew", "shift_jis", "cp1252"],
24+
["utf-8", "gb2312", "hebrew", "shift_jis", "cp1252"],
2525
)
2626
def test_get_encoded_zip_files(self, encoding):
2727
# See igor.py, do_zipmods, for the text of these files.

0 commit comments

Comments
 (0)