summaryrefslogtreecommitdiff
path: root/pygments
diff options
context:
space:
mode:
authorJean Abou Samra <jean@abou-samra.fr>2023-01-30 03:11:54 +0100
committerGeorg Brandl <georg@python.org>2023-01-31 16:30:11 +0100
commitb69cae00b4a13cf306ec92d169b81c965a0865fc (patch)
treea6bef750d9fd875d56ddb50279d151dce58ffe3c /pygments
parent94566ea3bf85190f21cb347ef5df7e5033e43b0f (diff)
downloadpygments-git-b69cae00b4a13cf306ec92d169b81c965a0865fc.tar.gz
Fix lots of missing encoding="utf-8" parameters
Some of these are probably unnecessary (ASCII-only content), but it's easier not to think about it.
Diffstat (limited to 'pygments')
-rw-r--r--pygments/formatters/html.py8
-rw-r--r--pygments/lexers/_lua_builtins.py4
-rw-r--r--pygments/lexers/_mysql_builtins.py4
-rw-r--r--pygments/lexers/_php_builtins.py6
-rw-r--r--pygments/lexers/_postgres_builtins.py4
-rw-r--r--pygments/lexers/_scilab_builtins.py4
-rw-r--r--pygments/lexers/_sourcemod_builtins.py4
-rw-r--r--pygments/unistring.py4
8 files changed, 19 insertions, 19 deletions
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py
index ee53f132..f19bef83 100644
--- a/pygments/formatters/html.py
+++ b/pygments/formatters/html.py
@@ -635,7 +635,7 @@ class HtmlFormatter(Formatter):
# write CSS file only if noclobber_cssfile isn't given as an option.
try:
if not os.path.exists(cssfilename) or not self.noclobber_cssfile:
- with open(cssfilename, "w") as cf:
+ with open(cssfilename, "w", encoding="utf-8") as cf:
cf.write(CSSFILE_TEMPLATE %
{'styledefs': self.get_style_defs('body')})
except OSError as err:
@@ -721,7 +721,7 @@ class HtmlFormatter(Formatter):
yield 0, dummyoutfile.getvalue()
yield 0, '</div>'
yield 0, '</td></tr></table>'
-
+
def _wrap_inlinelinenos(self, inner):
# need a list of lines since we need the width of a single number :(
@@ -946,9 +946,9 @@ class HtmlFormatter(Formatter):
output = source
if self.wrapcode:
output = self._wrap_code(output)
-
+
output = self._wrap_pre(output)
-
+
return output
def format_unencoded(self, tokensource, outfile):
diff --git a/pygments/lexers/_lua_builtins.py b/pygments/lexers/_lua_builtins.py
index a31f6b3b..39d5d5ef 100644
--- a/pygments/lexers/_lua_builtins.py
+++ b/pygments/lexers/_lua_builtins.py
@@ -249,14 +249,14 @@ if __name__ == '__main__': # pragma: no cover
return 'basic'
def regenerate(filename, modules):
- with open(filename) as fp:
+ with open(filename, encoding='utf-8') as fp:
content = fp.read()
header = content[:content.find('MODULES = {')]
footer = content[content.find("if __name__ == '__main__':"):]
- with open(filename, 'w') as fp:
+ with open(filename, 'w', encoding='utf-8') as fp:
fp.write(header)
fp.write('MODULES = %s\n\n' % pprint.pformat(modules))
fp.write(footer)
diff --git a/pygments/lexers/_mysql_builtins.py b/pygments/lexers/_mysql_builtins.py
index d266789c..cbcc9b8b 100644
--- a/pygments/lexers/_mysql_builtins.py
+++ b/pygments/lexers/_mysql_builtins.py
@@ -1317,7 +1317,7 @@ if __name__ == '__main__': # pragma: no cover
def update_content(field_name, content):
"""Overwrite this file with content parsed from MySQL's source code."""
- with open(__file__) as f:
+ with open(__file__, encoding="utf-8") as f:
data = f.read()
# Line to start/end inserting
@@ -1329,7 +1329,7 @@ if __name__ == '__main__': # pragma: no cover
new_block = format_lines(field_name, content)
data = data[:m.start()] + new_block + data[m.end():]
- with open(__file__, 'w', newline='\n') as f:
+ with open(__file__, 'w', encoding='utf-8', newline='\n') as f:
f.write(data)
update_myself()
diff --git a/pygments/lexers/_php_builtins.py b/pygments/lexers/_php_builtins.py
index a899f1d1..d93ab7bd 100644
--- a/pygments/lexers/_php_builtins.py
+++ b/pygments/lexers/_php_builtins.py
@@ -3267,7 +3267,7 @@ if __name__ == '__main__': # pragma: no cover
for file in get_php_references():
module = ''
- with open(file) as f:
+ with open(file, encoding='utf-8') as f:
for line in f:
if not module:
search = module_re.search(line)
@@ -3303,13 +3303,13 @@ if __name__ == '__main__': # pragma: no cover
os.remove(download[0])
def regenerate(filename, modules):
- with open(filename) as fp:
+ with open(filename, encoding='utf-8') as fp:
content = fp.read()
header = content[:content.find('MODULES = {')]
footer = content[content.find("if __name__ == '__main__':"):]
- with open(filename, 'w') as fp:
+ with open(filename, 'w', encoding='utf-8') as fp:
fp.write(header)
fp.write('MODULES = %s\n\n' % pprint.pformat(modules))
fp.write(footer)
diff --git a/pygments/lexers/_postgres_builtins.py b/pygments/lexers/_postgres_builtins.py
index 3305f845..a67cc825 100644
--- a/pygments/lexers/_postgres_builtins.py
+++ b/pygments/lexers/_postgres_builtins.py
@@ -665,7 +665,7 @@ if __name__ == '__main__': # pragma: no cover
return dt
def update_consts(filename, constname, content):
- with open(filename) as f:
+ with open(filename, encoding='utf-8') as f:
data = f.read()
# Line to start/end inserting
@@ -678,7 +678,7 @@ if __name__ == '__main__': # pragma: no cover
new_block = format_lines(constname, content)
data = data[:m.start()] + new_block + data[m.end():]
- with open(filename, 'w', newline='\n') as f:
+ with open(filename, 'w', encoding='utf-8', newline='\n') as f:
f.write(data)
update_myself()
diff --git a/pygments/lexers/_scilab_builtins.py b/pygments/lexers/_scilab_builtins.py
index c433bcfd..cfbf8488 100644
--- a/pygments/lexers/_scilab_builtins.py
+++ b/pygments/lexers/_scilab_builtins.py
@@ -3079,13 +3079,13 @@ mclose(fd)\n''' % var_type)
seen.update(set(new_data[t]))
- with open(__file__) as f:
+ with open(__file__, encoding='utf-8') as f:
content = f.read()
header = content[:content.find('# Autogenerated')]
footer = content[content.find("if __name__ == '__main__':"):]
- with open(__file__, 'w') as f:
+ with open(__file__, 'w', encoding='utf-8') as f:
f.write(header)
f.write('# Autogenerated\n\n')
for k, v in sorted(new_data.items()):
diff --git a/pygments/lexers/_sourcemod_builtins.py b/pygments/lexers/_sourcemod_builtins.py
index 6f1392dc..edafb1f0 100644
--- a/pygments/lexers/_sourcemod_builtins.py
+++ b/pygments/lexers/_sourcemod_builtins.py
@@ -1122,14 +1122,14 @@ if __name__ == '__main__': # pragma: no cover
return functions
def regenerate(filename, natives):
- with open(filename) as fp:
+ with open(filename, encoding='utf-8') as fp:
content = fp.read()
header = content[:content.find('FUNCTIONS = (')]
footer = content[content.find("if __name__ == '__main__':")-1:]
- with open(filename, 'w') as fp:
+ with open(filename, 'w', encoding='utf-8') as fp:
fp.write(header)
fp.write(format_lines('FUNCTIONS', natives))
fp.write('\n\n' + footer)
diff --git a/pygments/unistring.py b/pygments/unistring.py
index 2e3c8086..84a11f03 100644
--- a/pygments/unistring.py
+++ b/pygments/unistring.py
@@ -112,7 +112,7 @@ if __name__ == '__main__': # pragma: no cover
categories = {'xid_start': [], 'xid_continue': []}
- with open(__file__) as fp:
+ with open(__file__, encoding='utf-8') as fp:
content = fp.read()
header = content[:content.find('Cc =')]
@@ -136,7 +136,7 @@ if __name__ == '__main__': # pragma: no cover
if ('a' + c).isidentifier():
categories['xid_continue'].append(c)
- with open(__file__, 'w') as fp:
+ with open(__file__, 'w', encoding='utf-8') as fp:
fp.write(header)
for cat in sorted(categories):