diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-10 07:24:35 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-10 07:24:35 -0400 |
commit | 267622b11b730ec69bf34202fc6258a2614394c5 (patch) | |
tree | 2196c4a5b3d740efca14567de2d0fd33f33db44b | |
parent | 498b1484e466588a22cef520095f1fd0ed8b8ff8 (diff) | |
download | python-coveragepy-git-267622b11b730ec69bf34202fc6258a2614394c5.tar.gz |
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.
-rw-r--r-- | coverage/annotate.py | 2 | ||||
-rw-r--r-- | coverage/inorout.py | 2 | ||||
-rw-r--r-- | coverage/misc.py | 6 | ||||
-rw-r--r-- | coverage/phystokens.py | 4 | ||||
-rw-r--r-- | coverage/plugin.py | 4 | ||||
-rw-r--r-- | coverage/sqldata.py | 4 | ||||
-rw-r--r-- | igor.py | 2 | ||||
-rw-r--r-- | tests/goldtest.py | 2 | ||||
-rw-r--r-- | tests/helpers.py | 2 | ||||
-rw-r--r-- | tests/test_process.py | 2 | ||||
-rw-r--r-- | tests/test_python.py | 2 |
11 files changed, 16 insertions, 16 deletions
diff --git a/coverage/annotate.py b/coverage/annotate.py index a6ee4636..9ca1b80a 100644 --- a/coverage/annotate.py +++ b/coverage/annotate.py @@ -73,7 +73,7 @@ class AnnotateReporter: else: dest_file = fr.filename + ",cover" - with open(dest_file, 'w', encoding='utf8') as dest: + with open(dest_file, 'w', encoding='utf-8') as dest: i = 0 j = 0 covered = True diff --git a/coverage/inorout.py b/coverage/inorout.py index 75b0a9cc..496ced35 100644 --- a/coverage/inorout.py +++ b/coverage/inorout.py @@ -432,7 +432,7 @@ class InOrOut: # No point tracing a file we can't later write to SQLite. try: - filename.encode("utf8") + filename.encode("utf-8") except UnicodeEncodeError: return "non-encodable filename" diff --git a/coverage/misc.py b/coverage/misc.py index 30b75744..9c414d88 100644 --- a/coverage/misc.py +++ b/coverage/misc.py @@ -236,15 +236,15 @@ class Hasher: def update(self, v): """Add `v` to the hash, recursively if needed.""" - self.hash.update(str(type(v)).encode("utf8")) + self.hash.update(str(type(v)).encode("utf-8")) if isinstance(v, str): - self.hash.update(v.encode('utf8')) + self.hash.update(v.encode("utf-8")) elif isinstance(v, bytes): self.hash.update(v) elif v is None: pass elif isinstance(v, (int, float)): - self.hash.update(str(v).encode("utf8")) + self.hash.update(str(v).encode("utf-8")) elif isinstance(v, (tuple, list)): for e in v: self.update(e) diff --git a/coverage/phystokens.py b/coverage/phystokens.py index f06c0c27..b6b08d00 100644 --- a/coverage/phystokens.py +++ b/coverage/phystokens.py @@ -201,8 +201,8 @@ def compile_unicode(source, filename, mode): Python 2's compile() builtin has a stupid restriction: if the source string is Unicode, then it may not have a encoding declaration in it. Why not? - Who knows! It also decodes to utf8, and then tries to interpret those utf8 - bytes according to the encoding declaration. Why? Who knows! + Who knows! It also decodes to utf-8, and then tries to interpret those + utf-8 bytes according to the encoding declaration. Why? Who knows! This function neuters the coding declaration, and compiles it. diff --git a/coverage/plugin.py b/coverage/plugin.py index 5b38e336..8d149af9 100644 --- a/coverage/plugin.py +++ b/coverage/plugin.py @@ -359,12 +359,12 @@ class FileReporter: Returns a Unicode string. The base implementation simply reads the `self.filename` file and - decodes it as UTF8. Override this method if your file isn't readable + decodes it as UTF-8. Override this method if your file isn't readable as a text file, or if you need other encoding support. """ with open(self.filename, "rb") as f: - return f.read().decode("utf8") + return f.read().decode("utf-8") def lines(self): """Get the executable lines in this file. diff --git a/coverage/sqldata.py b/coverage/sqldata.py index 108a25ef..c4e950d3 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -349,7 +349,7 @@ class CoverageData(SimpleReprMixin): if self._debug.should("dataio"): self._debug.write(f"Dumping data from data file {self._filename!r}") with self._connect() as con: - return b"z" + zlib.compress(con.dump().encode("utf8")) + return b"z" + zlib.compress(con.dump().encode("utf-8")) @contract(data="bytes") def loads(self, data): @@ -373,7 +373,7 @@ class CoverageData(SimpleReprMixin): raise CoverageException( f"Unrecognized serialization: {data[:40]!r} (head of {len(data)} bytes)" ) - script = zlib.decompress(data[1:]).decode("utf8") + script = zlib.decompress(data[1:]).decode("utf-8") self._dbs[threading.get_ident()] = db = SqliteDb(self._filename, self._debug) with db: db.executescript(script) @@ -234,7 +234,7 @@ def do_zip_mods(): """) # These encodings should match the list in tests/test_python.py details = [ - ('utf8', 'ⓗⓔⓛⓛⓞ, ⓦⓞⓡⓛⓓ'), + ('utf-8', 'ⓗⓔⓛⓛⓞ, ⓦⓞⓡⓛⓓ'), ('gb2312', '你好,世界'), ('hebrew', 'שלום, עולם'), ('shift_jis', 'こんにちは世界'), diff --git a/tests/goldtest.py b/tests/goldtest.py index cd946efb..f2b7fe19 100644 --- a/tests/goldtest.py +++ b/tests/goldtest.py @@ -122,7 +122,7 @@ def canonicalize_xml(xtext): for node in root.iter(): node.attrib = dict(sorted(node.items())) xtext = xml.etree.ElementTree.tostring(root) - return xtext.decode('utf8') + return xtext.decode("utf-8") def contains(filename, *strlist): diff --git a/tests/helpers.py b/tests/helpers.py index 28adf78c..c85a36cb 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -69,7 +69,7 @@ def make_file(filename, text="", bytes=b"", newline=None): text = textwrap.dedent(text) if newline: text = text.replace("\n", newline) - data = text.encode('utf8') + data = text.encode("utf-8") # Make sure the directories are available. dirs, _ = os.path.split(filename) diff --git a/tests/test_process.py b/tests/test_process.py index af2d3e78..c41c57b7 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -759,7 +759,7 @@ class ProcessTest(CoverageTest): # Pypy passes locally, but fails in CI? Perhaps the version of macOS is # significant? https://foss.heptapod.net/pypy/pypy/-/issues/3074 @pytest.mark.skipif(env.PYPY, reason="PyPy is unreliable with this test") - # Jython as of 2.7.1rc3 won't compile a filename that isn't utf8. + # Jython as of 2.7.1rc3 won't compile a filename that isn't utf-8. @pytest.mark.skipif(env.JYTHON, reason="Jython can't handle this test") def test_lang_c(self): # LANG=C forces getfilesystemencoding on Linux to 'ascii', which causes diff --git a/tests/test_python.py b/tests/test_python.py index dc9609c9..5965ca06 100644 --- a/tests/test_python.py +++ b/tests/test_python.py @@ -21,7 +21,7 @@ class GetZipBytesTest(CoverageTest): @pytest.mark.parametrize( "encoding", - ["utf8", "gb2312", "hebrew", "shift_jis", "cp1252"], + ["utf-8", "gb2312", "hebrew", "shift_jis", "cp1252"], ) def test_get_encoded_zip_files(self, encoding): # See igor.py, do_zipmods, for the text of these files. |