From 0490027aa7af117be061b21f73073f080cfe7276 Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Tue, 7 May 2019 14:50:28 +0200 Subject: [PATCH 01/22] Fix encoding for files created for building package (issue #1027) This is minimal set of modifications, which fixed the problem. There are still more places, where files are open in text mode without explicit encoding, thus possibly failing on systems not using UTF-8 console encoding. --- poetry/masonry/api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry/masonry/api.py b/poetry/masonry/api.py index 7c5728ce63e..5d6dd330d1e 100644 --- a/poetry/masonry/api.py +++ b/poetry/masonry/api.py @@ -39,13 +39,13 @@ def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None): dist_info.mkdir() if "scripts" in poetry.local_config or "plugins" in poetry.local_config: - with (dist_info / "entry_points.txt").open("w") as f: + with (dist_info / "entry_points.txt").open("w", encoding="utf-8") as f: builder._write_entry_points(f) - with (dist_info / "WHEEL").open("w") as f: + with (dist_info / "WHEEL").open("w", encoding="utf-8") as f: builder._write_wheel_file(f) - with (dist_info / "METADATA").open("w") as f: + with (dist_info / "METADATA").open("w", encoding="utf-8") as f: builder._write_metadata_file(f) return dist_info.name From 8447a110b87b1569425fc6d8a69a66af39beecd2 Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Tue, 7 May 2019 18:02:11 +0200 Subject: [PATCH 02/22] test_api.py use explicit encoding for files. --- tests/masonry/test_api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/masonry/test_api.py b/tests/masonry/test_api.py index bea1fb26053..7238f4a3da6 100644 --- a/tests/masonry/test_api.py +++ b/tests/masonry/test_api.py @@ -117,11 +117,11 @@ def test_prepare_metadata_for_build_wheel(): assert (dist_info / "WHEEL").exists() assert (dist_info / "METADATA").exists() - with (dist_info / "entry_points.txt").open() as f: + with (dist_info / "entry_points.txt").open(encoding="utf-8") as f: assert entry_points == decode(f.read()) - with (dist_info / "WHEEL").open() as f: + with (dist_info / "WHEEL").open(encoding="utf-8") as f: assert wheel_data == decode(f.read()) - with (dist_info / "METADATA").open() as f: + with (dist_info / "METADATA").open(encoding="utf-8") as f: assert metadata == decode(f.read()) From 8ac5fdb9d01ea3e01f9f1411370bf81f47b165e7 Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 00:51:49 +0200 Subject: [PATCH 03/22] get-poetry.py: fix explicit (utf-8) encoding for files open in text mode --- get-poetry.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/get-poetry.py b/get-poetry.py index a5f1ffa4094..1e50b24854f 100644 --- a/get-poetry.py +++ b/get-poetry.py @@ -191,6 +191,7 @@ def expanduser(path): BIN = """#!/usr/bin/env python +# -*- coding: utf-8 -*- import glob import sys import os @@ -387,7 +388,10 @@ def _compare_versions(x, y): current_version = None if os.path.exists(POETRY_LIB): - with open(os.path.join(POETRY_LIB, "poetry", "__version__.py")) as f: + # explicit utf-8 for python source file + with open( + os.path.join(POETRY_LIB, "poetry", "__version__.py"), encoding="utf-8" + ) as f: version_content = f.read() current_version_re = re.match( @@ -561,6 +565,7 @@ def make_bin(self): os.mkdir(POETRY_BIN, 0o755) if WINDOWS: + # implicit system encoding for poetry.bat with open(os.path.join(POETRY_BIN, "poetry.bat"), "w") as f: f.write( BAT.format( @@ -570,7 +575,8 @@ def make_bin(self): ) ) - with open(os.path.join(POETRY_BIN, "poetry"), "w") as f: + # explicit utf-8 encoding for python source file + with open(os.path.join(POETRY_BIN, "poetry"), "w", encoding="utf-8") as f: f.write(BIN) if not WINDOWS: @@ -582,6 +588,7 @@ def make_env(self): if WINDOWS: return + # implicit system encoding for env with open(os.path.join(POETRY_HOME, "env"), "w") as f: f.write(self.get_export_string()) @@ -603,10 +610,12 @@ def update_path(self): if not os.path.exists(profile): continue + # implicit system encoding for profile with open(profile, "r") as f: content = f.read() if addition not in content: + # implicit system encoding for profile with open(profile, "a") as f: f.write(addition) @@ -700,6 +709,7 @@ def remove_from_unix_path(self): if not os.path.exists(profile): continue + # implicit system encoding for profile with open(profile, "r") as f: content = f.readlines() @@ -716,6 +726,7 @@ def remove_from_unix_path(self): new_content.append(line) + # implicit system encoding for profile with open(profile, "w") as f: f.writelines(new_content) From d632ce24a34fd09a891193069020864e2ea83e89 Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 00:52:07 +0200 Subject: [PATCH 04/22] tests: fix explicit (utf-8) encoding for files open in text mode --- tests/console/conftest.py | 6 ++++-- .../git/github.com/demo/no-version/setup.py | 5 ++++- tests/repositories/test_legacy_repository.py | 3 ++- tests/repositories/test_pypi_repository.py | 3 ++- tests/utils/fixtures/setups/ansible/setup.py | 10 +++++++--- tests/utils/fixtures/setups/pyyaml/setup.py | 15 ++++++++++----- tests/utils/fixtures/setups/sqlalchemy/setup.py | 9 +++++++-- 7 files changed, 36 insertions(+), 15 deletions(-) diff --git a/tests/console/conftest.py b/tests/console/conftest.py index 509b94b7bf8..a3d4430c694 100644 --- a/tests/console/conftest.py +++ b/tests/console/conftest.py @@ -176,7 +176,8 @@ def repo(): def poetry(repo): p = Poetry.create(Path(__file__).parent.parent / "fixtures" / "simple_project") - with p.file.path.open() as f: + # explicit utf-8 for poetry file + with p.file.path.open(encoding="utf-8") as f: content = f.read() p.pool.remove_repository("pypi") @@ -184,7 +185,8 @@ def poetry(repo): yield p - with p.file.path.open("w") as f: + # explicit utf-8 for poetry file + with p.file.path.open("w", encoding="utf-8") as f: f.write(content) diff --git a/tests/fixtures/git/github.com/demo/no-version/setup.py b/tests/fixtures/git/github.com/demo/no-version/setup.py index 4e1aea3034c..4d6c7374a22 100644 --- a/tests/fixtures/git/github.com/demo/no-version/setup.py +++ b/tests/fixtures/git/github.com/demo/no-version/setup.py @@ -6,7 +6,10 @@ def read_version(): - with open(os.path.join(os.path.dirname(__file__), "demo", "__init__.py")) as f: + # explicit utf-8 for python source + with open( + os.path.join(os.path.dirname(__file__), "demo", "__init__.py"), encoding="utf-8" + ) as f: for line in f: if line.startswith("__version__ = "): return ast.literal_eval(line[len("__version__ = ") :].strip()) diff --git a/tests/repositories/test_legacy_repository.py b/tests/repositories/test_legacy_repository.py index ac20393d206..7c0330a26d5 100644 --- a/tests/repositories/test_legacy_repository.py +++ b/tests/repositories/test_legacy_repository.py @@ -29,7 +29,8 @@ def _get(self, endpoint): fixture = self.FIXTURES / (name + ".html") - with fixture.open() as f: + # explicit utf-8 for HTML + with fixture.open(encoding="utf-8") as f: return Page(self._url + endpoint, f.read(), {}) def _download(self, url, dest): diff --git a/tests/repositories/test_pypi_repository.py b/tests/repositories/test_pypi_repository.py index 82c696c475e..f5d1d906f89 100644 --- a/tests/repositories/test_pypi_repository.py +++ b/tests/repositories/test_pypi_repository.py @@ -33,7 +33,8 @@ def _get(self, url): if not fixture.exists(): fixture = self.JSON_FIXTURES / (name + ".json") - with fixture.open() as f: + # explicit utf-8 for JSON + with fixture.open(encoding="utf-8") as f: return json.loads(f.read()) def _download(self, url, dest): diff --git a/tests/utils/fixtures/setups/ansible/setup.py b/tests/utils/fixtures/setups/ansible/setup.py index 5d7d1f4ec60..4f6728c7a2d 100644 --- a/tests/utils/fixtures/setups/ansible/setup.py +++ b/tests/utils/fixtures/setups/ansible/setup.py @@ -54,7 +54,8 @@ def _find_symlinks(topdir, extension=""): def _cache_symlinks(symlink_data): - with open(SYMLINK_CACHE, "w") as f: + # explicit utf-8 for JSON + with open(SYMLINK_CACHE, "w", encoding="utf-8") as f: json.dump(symlink_data, f) @@ -63,7 +64,9 @@ def _maintain_symlinks(symlink_type, base_path): try: # Try the cache first because going from git checkout to sdist is the # only time we know that we're going to cache correctly - with open(SYMLINK_CACHE, "r") as f: + + # explicit utf-8 for JSON + with open(SYMLINK_CACHE, "r", encoding="utf-8") as f: symlink_data = json.load(f) except (IOError, OSError) as e: # IOError on py2, OSError on py3. Both have errno @@ -139,7 +142,8 @@ def run(self): def read_file(file_name): """Read file and return its contents.""" - with open(file_name, "r") as f: + # explicit utf-8 for file such as requirements.txt + with open(file_name, "r", encoding="utf-8") as f: return f.read() diff --git a/tests/utils/fixtures/setups/pyyaml/setup.py b/tests/utils/fixtures/setups/pyyaml/setup.py index 5285386ba55..9c8de659531 100644 --- a/tests/utils/fixtures/setups/pyyaml/setup.py +++ b/tests/utils/fixtures/setups/pyyaml/setup.py @@ -215,14 +215,16 @@ def build_extensions(self): def check_extension_availability(self, ext): cache = os.path.join(self.build_temp, "check_%s.out" % ext.feature_name) if not self.force and os.path.isfile(cache): - data = open(cache).read().strip() + # explicit utf-8 + data = open(cache, encoding="utf-8").read().strip() if data == "1": return True elif data == "0": return False mkpath(self.build_temp) src = os.path.join(self.build_temp, "check_%s.c" % ext.feature_name) - open(src, "w").write(ext.feature_check) + # explicit utf-8 + open(src, "w", encoding="utf-8").write(ext.feature_check) log.info("checking if %s is compilable" % ext.feature_name) try: [obj] = self.compiler.compile( @@ -243,7 +245,8 @@ def check_extension_availability(self, ext): ) log.warn(" specify the option --include-dirs or uncomment and") log.warn(" modify the parameter include_dirs in setup.cfg)") - open(cache, "w").write("0\n") + # explicit utf-8 (to keep the style) + open(cache, "w", encoding="utf-8").write("0\n") return False prog = "check_%s" % ext.feature_name log.info("checking if %s is linkable" % ext.feature_name) @@ -268,9 +271,11 @@ def check_extension_availability(self, ext): ) log.warn(" specify the option --library-dirs or uncomment and") log.warn(" modify the parameter library_dirs in setup.cfg)") - open(cache, "w").write("0\n") + # expplicit utf-8 (to keep the style) + open(cache, "w", encoding="utf-8").write("0\n") return False - open(cache, "w").write("1\n") + # expplicit utf-8 (to keep the style) + open(cache, "w", encoding="utf-8").write("1\n") return True diff --git a/tests/utils/fixtures/setups/sqlalchemy/setup.py b/tests/utils/fixtures/setups/sqlalchemy/setup.py index 8842a482d27..34b450d8864 100644 --- a/tests/utils/fixtures/setups/sqlalchemy/setup.py +++ b/tests/utils/fixtures/setups/sqlalchemy/setup.py @@ -112,12 +112,17 @@ def status_msgs(*msgs): print("*" * 75) +# explicit utf-8 for python source with open( - os.path.join(os.path.dirname(__file__), "lib", "sqlalchemy", "__init__.py") + os.path.join(os.path.dirname(__file__), "lib", "sqlalchemy", "__init__.py"), + encoding="utf-8", ) as v_file: VERSION = re.compile(r".*__version__ = '(.*?)'", re.S).match(v_file.read()).group(1) -with open(os.path.join(os.path.dirname(__file__), "README.rst")) as r_file: +# explicit utf-8 for readme +with open( + os.path.join(os.path.dirname(__file__), "README.rst"), encoding="utf-8" +) as r_file: readme = r_file.read() From 0f21d562dc3f913c74f3348ef3df8979409937b6 Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 00:53:00 +0200 Subject: [PATCH 05/22] poetry init: use explicit utf-8 for created pyproject.toml --- poetry/console/commands/init.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/poetry/console/commands/init.py b/poetry/console/commands/init.py index bd92898148a..24672b8a444 100644 --- a/poetry/console/commands/init.py +++ b/poetry/console/commands/init.py @@ -158,7 +158,8 @@ def handle(self): return 1 - with (Path.cwd() / "pyproject.toml").open("w") as f: + # explicit utf-8 for pyproject.toml + with (Path.cwd() / "pyproject.toml").open("w", encoding="utf-8") as f: f.write(content) def _determine_requirements( From 87e84096e76b2c724c169f5ee1cc0f933c2fc6be Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 00:53:55 +0200 Subject: [PATCH 06/22] installed: use explicit utf-8 for text files --- poetry/installation/pip_installer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/poetry/installation/pip_installer.py b/poetry/installation/pip_installer.py index 68a8af7b795..ab7fbfb7cdb 100644 --- a/poetry/installation/pip_installer.py +++ b/poetry/installation/pip_installer.py @@ -193,7 +193,8 @@ def install_directory(self, package): # We also need it for non-PEP-517 packages builder = SdistBuilder(Poetry.create(pyproject.parent), NullEnv(), NullIO()) - with open(setup, "w") as f: + # explicit utf-8 for python source + with open(setup, "w", encoding="utf-8") as f: f.write(decode(builder.build_setup())) if package.develop: From 4154179035bf72631339053b83c78e3ec285fb3e Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 00:54:21 +0200 Subject: [PATCH 07/22] layouts: use explicit utf-8 for open text files --- poetry/layouts/layout.py | 6 ++++-- poetry/layouts/src.py | 3 ++- poetry/layouts/standard.py | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/poetry/layouts/layout.py b/poetry/layouts/layout.py index d99e842c1bc..47a31c12507 100644 --- a/poetry/layouts/layout.py +++ b/poetry/layouts/layout.py @@ -140,7 +140,8 @@ def _create_tests(self, path): tests.mkdir() tests_init.touch(exist_ok=False) - with tests_default.open("w") as f: + # explicit utf-8 for python source + with tests_default.open("w", encoding="utf-8") as f: f.write( TESTS_DEFAULT.format( package_name=self._package_name, version=self._version @@ -152,5 +153,6 @@ def _write_poetry(self, path): poetry = path / "pyproject.toml" - with poetry.open("w") as f: + # explicit utf-8 for python source + with poetry.open("w", encoding="utf-8") as f: f.write(content) diff --git a/poetry/layouts/src.py b/poetry/layouts/src.py index 9f715262b1c..c76c82fbda7 100644 --- a/poetry/layouts/src.py +++ b/poetry/layouts/src.py @@ -14,5 +14,6 @@ def _create_default(self, path): package_path.mkdir(parents=True) - with package_init.open("w") as f: + # explicit utf-8 for python source + with package_init.open("w", encoding="utf-8") as f: f.write(DEFAULT.format(version=self._version)) diff --git a/poetry/layouts/standard.py b/poetry/layouts/standard.py index ae0c7f75eb6..b62ed0cdd98 100644 --- a/poetry/layouts/standard.py +++ b/poetry/layouts/standard.py @@ -14,5 +14,6 @@ def _create_default(self, path): package_path.mkdir() - with package_init.open("w") as f: + #explicit utf-8 for python source + with package_init.open("w", encoding="utf-8") as f: f.write(DEFAULT.format(version=self._version)) From d9da150330d23d519ab4a3f37ff27f41a501462c Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 00:54:40 +0200 Subject: [PATCH 08/22] spdx: explicit utf-8 for open text files --- poetry/spdx/__init__.py | 3 ++- poetry/spdx/updater.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/poetry/spdx/__init__.py b/poetry/spdx/__init__.py index 7afb5a56059..3312f162a32 100644 --- a/poetry/spdx/__init__.py +++ b/poetry/spdx/__init__.py @@ -26,7 +26,8 @@ def load_licenses(): licenses_file = os.path.join(os.path.dirname(__file__), "data", "licenses.json") - with open(licenses_file) as f: + # explicit utf-8 for JSON + with open(licenses_file, encoding="utf-8") as f: data = json.loads(f.read()) for name, license in data.items(): diff --git a/poetry/spdx/updater.py b/poetry/spdx/updater.py index 693c7b86c0b..19dc8c40159 100644 --- a/poetry/spdx/updater.py +++ b/poetry/spdx/updater.py @@ -20,7 +20,8 @@ def dump(self, file=None): licenses_url = self._base_url + "licenses.json" - with open(file, "w") as f: + # explicit utf-8 for JSON + with open(file, "w", encoding="utf-8") as f: f.write( json.dumps(self.get_licenses(licenses_url), indent=2, sort_keys=True) ) From 17740172f4f3166db0173fca9a1289dc51140813 Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 00:55:09 +0200 Subject: [PATCH 09/22] pypi_repository: explicit utf-8 for open text files --- poetry/repositories/pypi_repository.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/poetry/repositories/pypi_repository.py b/poetry/repositories/pypi_repository.py index acd9fb9dae0..119b38b3ebb 100644 --- a/poetry/repositories/pypi_repository.py +++ b/poetry/repositories/pypi_repository.py @@ -533,7 +533,8 @@ def _get_info_from_sdist( requires = egg_info / "requires.txt" if requires.exists(): - with requires.open() as f: + # explicit utf-8 for requires.txt + with requires.open(encoding="utf-8") as f: info["requires_dist"] = parse_requires(f.read()) return info @@ -545,7 +546,8 @@ def _get_info_from_sdist( requires = egg_info / "requires.txt" if requires.exists(): - with requires.open() as f: + # explicit utf-8 for requires.txt + with requires.open(encoding="utf-8") as f: info["requires_dist"] = parse_requires(f.read()) return info From aff472c0a5b3b8aa68e73d352139261491722a2a Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 00:56:09 +0200 Subject: [PATCH 10/22] explicit utf-8 for json --- poetry/json/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/poetry/json/__init__.py b/poetry/json/__init__.py index 425ee6228ff..357744f6f6d 100644 --- a/poetry/json/__init__.py +++ b/poetry/json/__init__.py @@ -19,7 +19,8 @@ def validate_object(obj, schema_name): # type: (dict, str) -> List[str] if not os.path.exists(schema): raise ValueError("Schema {} does not exist.".format(schema_name)) - with open(schema) as f: + # explicit utf-8 for JSON + with open(schema, encoding="utf-8") as f: schema = json.loads(f.read()) validator = jsonschema.Draft7Validator(schema) From dadbe50f37fd08f7fdb855b7a9c3d71ea1f30704 Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 00:56:27 +0200 Subject: [PATCH 11/22] explicit utf-8 for metadata --- poetry/masonry/metadata.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/poetry/masonry/metadata.py b/poetry/masonry/metadata.py index a48b931ee73..9b3dff3a928 100644 --- a/poetry/masonry/metadata.py +++ b/poetry/masonry/metadata.py @@ -46,7 +46,8 @@ def from_package(cls, package): # type: (...) -> Metadata meta.version = normalize_version(package.version.text) meta.summary = package.description if package.readme: - with package.readme.open() as f: + # explicit utf-8 for readme + with package.readme.open(encoding="utf-8") as f: meta.description = f.read() meta.keywords = ",".join(package.keywords) From 7cc64b61a240579a4a810bcc5edb26da8b42f5e4 Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 00:56:49 +0200 Subject: [PATCH 12/22] explicit utf-8 for requires.txt --- poetry/puzzle/provider.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/poetry/puzzle/provider.py b/poetry/puzzle/provider.py index 38c9479d61d..4ac8500f3e9 100644 --- a/poetry/puzzle/provider.py +++ b/poetry/puzzle/provider.py @@ -346,7 +346,8 @@ def search_for_directory( reqs = [] requires = egg_info / "requires.txt" if requires.exists(): - with requires.open() as f: + # explicit utf-8 for requires.txt + with requires.open(encoding="utf-8") as f: reqs = parse_requires(f.read()) finally: os.chdir(current_dir) From 04004f4f308fc7859b189016d31f5b12bb2ab0da Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 01:16:16 +0200 Subject: [PATCH 13/22] open files with explicit encoding in py27 --- get-poetry.py | 2 +- poetry/json/__init__.py | 1 + poetry/spdx/__init__.py | 2 ++ poetry/spdx/updater.py | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/get-poetry.py b/get-poetry.py index 1e50b24854f..8498ba7bf7f 100644 --- a/get-poetry.py +++ b/get-poetry.py @@ -33,7 +33,7 @@ from contextlib import contextmanager from functools import cmp_to_key from gzip import GzipFile -from io import UnsupportedOperation +from io import UnsupportedOperation, open try: from urllib.error import HTTPError diff --git a/poetry/json/__init__.py b/poetry/json/__init__.py index 357744f6f6d..ddd498000bb 100644 --- a/poetry/json/__init__.py +++ b/poetry/json/__init__.py @@ -3,6 +3,7 @@ import jsonschema +from io import open from typing import List SCHEMA_DIR = os.path.join(os.path.dirname(__file__), "schemas") diff --git a/poetry/spdx/__init__.py b/poetry/spdx/__init__.py index 3312f162a32..fda57fb07bc 100644 --- a/poetry/spdx/__init__.py +++ b/poetry/spdx/__init__.py @@ -1,6 +1,8 @@ import json import os +from io import open + from .license import License from .updater import Updater diff --git a/poetry/spdx/updater.py b/poetry/spdx/updater.py index 19dc8c40159..a6c0e836799 100644 --- a/poetry/spdx/updater.py +++ b/poetry/spdx/updater.py @@ -1,6 +1,8 @@ import json import os +from io import open + try: from urllib.request import urlopen except ImportError: From 0ffe80b5e58264176a3b8b59dc89e8afa8877f81 Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 01:28:17 +0200 Subject: [PATCH 14/22] fix creation of poetry.bat on Windows --- get-poetry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get-poetry.py b/get-poetry.py index 8498ba7bf7f..740c7a32b46 100644 --- a/get-poetry.py +++ b/get-poetry.py @@ -206,7 +206,7 @@ def expanduser(path): main() """ -BAT = '@echo off\r\npython "{poetry_bin}" %*\r\n' +BAT = u'@echo off\r\npython "{poetry_bin}" %*\r\n' PRE_MESSAGE = """# Welcome to {poetry}! From a06efff91af0533ab58448cb6d34d03dfa920fe4 Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 01:50:47 +0200 Subject: [PATCH 15/22] Make get-poetry.py compatible to py2/3 --- get-poetry.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/get-poetry.py b/get-poetry.py index 740c7a32b46..3a541ee7d10 100644 --- a/get-poetry.py +++ b/get-poetry.py @@ -58,6 +58,10 @@ except ImportError: winreg = None +try: + u = unicode +except NameError: + u = str WINDOWS = sys.platform.startswith("win") or (sys.platform == "cli" and os.name == "nt") @@ -206,7 +210,7 @@ def expanduser(path): main() """ -BAT = u'@echo off\r\npython "{poetry_bin}" %*\r\n' +BAT = u('@echo off\r\npython "{poetry_bin}" %*\r\n') PRE_MESSAGE = """# Welcome to {poetry}! @@ -568,16 +572,18 @@ def make_bin(self): # implicit system encoding for poetry.bat with open(os.path.join(POETRY_BIN, "poetry.bat"), "w") as f: f.write( - BAT.format( - poetry_bin=os.path.join(POETRY_BIN, "poetry").replace( - os.environ["USERPROFILE"], "%USERPROFILE%" + u( + BAT.format( + poetry_bin=os.path.join(POETRY_BIN, "poetry").replace( + os.environ["USERPROFILE"], "%USERPROFILE%" + ) ) ) ) # explicit utf-8 encoding for python source file with open(os.path.join(POETRY_BIN, "poetry"), "w", encoding="utf-8") as f: - f.write(BIN) + f.write(u(BIN)) if not WINDOWS: # Making the file executable @@ -590,7 +596,7 @@ def make_env(self): # implicit system encoding for env with open(os.path.join(POETRY_HOME, "env"), "w") as f: - f.write(self.get_export_string()) + f.write(u(self.get_export_string())) def update_path(self): """ @@ -617,7 +623,7 @@ def update_path(self): if addition not in content: # implicit system encoding for profile with open(profile, "a") as f: - f.write(addition) + f.write(u(addition)) updated.append(os.path.relpath(profile, HOME)) From c4853999f755d0f894a6af474dc3b9a8accab8cc Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Wed, 8 May 2019 01:58:49 +0200 Subject: [PATCH 16/22] Blacked two files to pass linter test --- poetry/layouts/standard.py | 2 +- tests/utils/fixtures/setups/ansible/setup.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry/layouts/standard.py b/poetry/layouts/standard.py index b62ed0cdd98..c5745a6de18 100644 --- a/poetry/layouts/standard.py +++ b/poetry/layouts/standard.py @@ -14,6 +14,6 @@ def _create_default(self, path): package_path.mkdir() - #explicit utf-8 for python source + # explicit utf-8 for python source with package_init.open("w", encoding="utf-8") as f: f.write(DEFAULT.format(version=self._version)) diff --git a/tests/utils/fixtures/setups/ansible/setup.py b/tests/utils/fixtures/setups/ansible/setup.py index 4f6728c7a2d..971fd1fcde3 100644 --- a/tests/utils/fixtures/setups/ansible/setup.py +++ b/tests/utils/fixtures/setups/ansible/setup.py @@ -6,11 +6,12 @@ import re import sys import warnings - from collections import defaultdict from distutils.command.build_scripts import build_scripts as BuildScripts from distutils.command.sdist import sdist as SDist +from ansible.release import __author__, __version__ + try: from setuptools import setup, find_packages from setuptools.command.build_py import build_py as BuildPy @@ -26,7 +27,6 @@ sys.exit(1) sys.path.insert(0, os.path.abspath("lib")) -from ansible.release import __version__, __author__ SYMLINK_CACHE = "SYMLINK_CACHE.json" @@ -64,7 +64,7 @@ def _maintain_symlinks(symlink_type, base_path): try: # Try the cache first because going from git checkout to sdist is the # only time we know that we're going to cache correctly - + # explicit utf-8 for JSON with open(SYMLINK_CACHE, "r", encoding="utf-8") as f: symlink_data = json.load(f) From ceaa73778b75af476a41542383dc512d5912b3b4 Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Mon, 3 Jun 2019 21:27:08 +0200 Subject: [PATCH 17/22] remove extranous encoding related comments --- get-poetry.py | 7 ------- poetry/installation/pip_installer.py | 1 - poetry/layouts/layout.py | 2 -- poetry/layouts/src.py | 1 - poetry/layouts/standard.py | 1 - poetry/spdx/__init__.py | 1 - poetry/spdx/updater.py | 1 - 7 files changed, 14 deletions(-) diff --git a/get-poetry.py b/get-poetry.py index 3a541ee7d10..d17f523599a 100644 --- a/get-poetry.py +++ b/get-poetry.py @@ -569,7 +569,6 @@ def make_bin(self): os.mkdir(POETRY_BIN, 0o755) if WINDOWS: - # implicit system encoding for poetry.bat with open(os.path.join(POETRY_BIN, "poetry.bat"), "w") as f: f.write( u( @@ -581,7 +580,6 @@ def make_bin(self): ) ) - # explicit utf-8 encoding for python source file with open(os.path.join(POETRY_BIN, "poetry"), "w", encoding="utf-8") as f: f.write(u(BIN)) @@ -594,7 +592,6 @@ def make_env(self): if WINDOWS: return - # implicit system encoding for env with open(os.path.join(POETRY_HOME, "env"), "w") as f: f.write(u(self.get_export_string())) @@ -616,12 +613,10 @@ def update_path(self): if not os.path.exists(profile): continue - # implicit system encoding for profile with open(profile, "r") as f: content = f.read() if addition not in content: - # implicit system encoding for profile with open(profile, "a") as f: f.write(u(addition)) @@ -715,7 +710,6 @@ def remove_from_unix_path(self): if not os.path.exists(profile): continue - # implicit system encoding for profile with open(profile, "r") as f: content = f.readlines() @@ -732,7 +726,6 @@ def remove_from_unix_path(self): new_content.append(line) - # implicit system encoding for profile with open(profile, "w") as f: f.writelines(new_content) diff --git a/poetry/installation/pip_installer.py b/poetry/installation/pip_installer.py index ab7fbfb7cdb..335f8aa3630 100644 --- a/poetry/installation/pip_installer.py +++ b/poetry/installation/pip_installer.py @@ -193,7 +193,6 @@ def install_directory(self, package): # We also need it for non-PEP-517 packages builder = SdistBuilder(Poetry.create(pyproject.parent), NullEnv(), NullIO()) - # explicit utf-8 for python source with open(setup, "w", encoding="utf-8") as f: f.write(decode(builder.build_setup())) diff --git a/poetry/layouts/layout.py b/poetry/layouts/layout.py index 47a31c12507..e46ade211ad 100644 --- a/poetry/layouts/layout.py +++ b/poetry/layouts/layout.py @@ -140,7 +140,6 @@ def _create_tests(self, path): tests.mkdir() tests_init.touch(exist_ok=False) - # explicit utf-8 for python source with tests_default.open("w", encoding="utf-8") as f: f.write( TESTS_DEFAULT.format( @@ -153,6 +152,5 @@ def _write_poetry(self, path): poetry = path / "pyproject.toml" - # explicit utf-8 for python source with poetry.open("w", encoding="utf-8") as f: f.write(content) diff --git a/poetry/layouts/src.py b/poetry/layouts/src.py index c76c82fbda7..8ad9ff7b9be 100644 --- a/poetry/layouts/src.py +++ b/poetry/layouts/src.py @@ -14,6 +14,5 @@ def _create_default(self, path): package_path.mkdir(parents=True) - # explicit utf-8 for python source with package_init.open("w", encoding="utf-8") as f: f.write(DEFAULT.format(version=self._version)) diff --git a/poetry/layouts/standard.py b/poetry/layouts/standard.py index c5745a6de18..4e8aa74d7f9 100644 --- a/poetry/layouts/standard.py +++ b/poetry/layouts/standard.py @@ -14,6 +14,5 @@ def _create_default(self, path): package_path.mkdir() - # explicit utf-8 for python source with package_init.open("w", encoding="utf-8") as f: f.write(DEFAULT.format(version=self._version)) diff --git a/poetry/spdx/__init__.py b/poetry/spdx/__init__.py index fda57fb07bc..8709845a9fd 100644 --- a/poetry/spdx/__init__.py +++ b/poetry/spdx/__init__.py @@ -28,7 +28,6 @@ def load_licenses(): licenses_file = os.path.join(os.path.dirname(__file__), "data", "licenses.json") - # explicit utf-8 for JSON with open(licenses_file, encoding="utf-8") as f: data = json.loads(f.read()) diff --git a/poetry/spdx/updater.py b/poetry/spdx/updater.py index a6c0e836799..895d595f83c 100644 --- a/poetry/spdx/updater.py +++ b/poetry/spdx/updater.py @@ -22,7 +22,6 @@ def dump(self, file=None): licenses_url = self._base_url + "licenses.json" - # explicit utf-8 for JSON with open(file, "w", encoding="utf-8") as f: f.write( json.dumps(self.get_licenses(licenses_url), indent=2, sort_keys=True) From c0c078e1de21ce6ea9ab98dcb32af7a0ca601d9d Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Sun, 23 Jun 2019 21:18:26 +0200 Subject: [PATCH 18/22] rewert broken move of import related to ansible --- tests/utils/fixtures/setups/ansible/setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/utils/fixtures/setups/ansible/setup.py b/tests/utils/fixtures/setups/ansible/setup.py index 971fd1fcde3..63a641aefa2 100644 --- a/tests/utils/fixtures/setups/ansible/setup.py +++ b/tests/utils/fixtures/setups/ansible/setup.py @@ -10,8 +10,6 @@ from distutils.command.build_scripts import build_scripts as BuildScripts from distutils.command.sdist import sdist as SDist -from ansible.release import __author__, __version__ - try: from setuptools import setup, find_packages from setuptools.command.build_py import build_py as BuildPy @@ -27,6 +25,7 @@ sys.exit(1) sys.path.insert(0, os.path.abspath("lib")) +from ansible.release import __author__, __version__ SYMLINK_CACHE = "SYMLINK_CACHE.json" From 0996dfce2b97a607fe91c758501c0f615db4a51b Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Sun, 23 Jun 2019 21:22:03 +0200 Subject: [PATCH 19/22] removed extraneous comments about opening files in UTF-8 --- get-poetry.py | 1 - poetry/console/commands/init.py | 1 - poetry/json/__init__.py | 1 - poetry/masonry/metadata.py | 1 - poetry/puzzle/provider.py | 1 - poetry/repositories/pypi_repository.py | 2 -- tests/console/conftest.py | 2 -- tests/fixtures/git/github.com/demo/no-version/setup.py | 1 - tests/repositories/test_legacy_repository.py | 1 - tests/repositories/test_pypi_repository.py | 1 - tests/utils/fixtures/setups/ansible/setup.py | 3 --- tests/utils/fixtures/setups/pyyaml/setup.py | 3 --- tests/utils/fixtures/setups/sqlalchemy/setup.py | 2 -- 13 files changed, 20 deletions(-) diff --git a/get-poetry.py b/get-poetry.py index d17f523599a..e369c866d32 100644 --- a/get-poetry.py +++ b/get-poetry.py @@ -392,7 +392,6 @@ def _compare_versions(x, y): current_version = None if os.path.exists(POETRY_LIB): - # explicit utf-8 for python source file with open( os.path.join(POETRY_LIB, "poetry", "__version__.py"), encoding="utf-8" ) as f: diff --git a/poetry/console/commands/init.py b/poetry/console/commands/init.py index 24672b8a444..93dfc610db6 100644 --- a/poetry/console/commands/init.py +++ b/poetry/console/commands/init.py @@ -158,7 +158,6 @@ def handle(self): return 1 - # explicit utf-8 for pyproject.toml with (Path.cwd() / "pyproject.toml").open("w", encoding="utf-8") as f: f.write(content) diff --git a/poetry/json/__init__.py b/poetry/json/__init__.py index ddd498000bb..24452baca66 100644 --- a/poetry/json/__init__.py +++ b/poetry/json/__init__.py @@ -20,7 +20,6 @@ def validate_object(obj, schema_name): # type: (dict, str) -> List[str] if not os.path.exists(schema): raise ValueError("Schema {} does not exist.".format(schema_name)) - # explicit utf-8 for JSON with open(schema, encoding="utf-8") as f: schema = json.loads(f.read()) diff --git a/poetry/masonry/metadata.py b/poetry/masonry/metadata.py index 9b3dff3a928..73041758ea4 100644 --- a/poetry/masonry/metadata.py +++ b/poetry/masonry/metadata.py @@ -46,7 +46,6 @@ def from_package(cls, package): # type: (...) -> Metadata meta.version = normalize_version(package.version.text) meta.summary = package.description if package.readme: - # explicit utf-8 for readme with package.readme.open(encoding="utf-8") as f: meta.description = f.read() diff --git a/poetry/puzzle/provider.py b/poetry/puzzle/provider.py index 4ac8500f3e9..13798e13a3d 100644 --- a/poetry/puzzle/provider.py +++ b/poetry/puzzle/provider.py @@ -346,7 +346,6 @@ def search_for_directory( reqs = [] requires = egg_info / "requires.txt" if requires.exists(): - # explicit utf-8 for requires.txt with requires.open(encoding="utf-8") as f: reqs = parse_requires(f.read()) finally: diff --git a/poetry/repositories/pypi_repository.py b/poetry/repositories/pypi_repository.py index 119b38b3ebb..7fa356fc061 100644 --- a/poetry/repositories/pypi_repository.py +++ b/poetry/repositories/pypi_repository.py @@ -533,7 +533,6 @@ def _get_info_from_sdist( requires = egg_info / "requires.txt" if requires.exists(): - # explicit utf-8 for requires.txt with requires.open(encoding="utf-8") as f: info["requires_dist"] = parse_requires(f.read()) @@ -546,7 +545,6 @@ def _get_info_from_sdist( requires = egg_info / "requires.txt" if requires.exists(): - # explicit utf-8 for requires.txt with requires.open(encoding="utf-8") as f: info["requires_dist"] = parse_requires(f.read()) diff --git a/tests/console/conftest.py b/tests/console/conftest.py index a3d4430c694..3f861f4a381 100644 --- a/tests/console/conftest.py +++ b/tests/console/conftest.py @@ -176,7 +176,6 @@ def repo(): def poetry(repo): p = Poetry.create(Path(__file__).parent.parent / "fixtures" / "simple_project") - # explicit utf-8 for poetry file with p.file.path.open(encoding="utf-8") as f: content = f.read() @@ -185,7 +184,6 @@ def poetry(repo): yield p - # explicit utf-8 for poetry file with p.file.path.open("w", encoding="utf-8") as f: f.write(content) diff --git a/tests/fixtures/git/github.com/demo/no-version/setup.py b/tests/fixtures/git/github.com/demo/no-version/setup.py index 4d6c7374a22..bb960775c26 100644 --- a/tests/fixtures/git/github.com/demo/no-version/setup.py +++ b/tests/fixtures/git/github.com/demo/no-version/setup.py @@ -6,7 +6,6 @@ def read_version(): - # explicit utf-8 for python source with open( os.path.join(os.path.dirname(__file__), "demo", "__init__.py"), encoding="utf-8" ) as f: diff --git a/tests/repositories/test_legacy_repository.py b/tests/repositories/test_legacy_repository.py index 7c0330a26d5..415a266585f 100644 --- a/tests/repositories/test_legacy_repository.py +++ b/tests/repositories/test_legacy_repository.py @@ -29,7 +29,6 @@ def _get(self, endpoint): fixture = self.FIXTURES / (name + ".html") - # explicit utf-8 for HTML with fixture.open(encoding="utf-8") as f: return Page(self._url + endpoint, f.read(), {}) diff --git a/tests/repositories/test_pypi_repository.py b/tests/repositories/test_pypi_repository.py index f5d1d906f89..6b32b915feb 100644 --- a/tests/repositories/test_pypi_repository.py +++ b/tests/repositories/test_pypi_repository.py @@ -33,7 +33,6 @@ def _get(self, url): if not fixture.exists(): fixture = self.JSON_FIXTURES / (name + ".json") - # explicit utf-8 for JSON with fixture.open(encoding="utf-8") as f: return json.loads(f.read()) diff --git a/tests/utils/fixtures/setups/ansible/setup.py b/tests/utils/fixtures/setups/ansible/setup.py index 63a641aefa2..920c25148db 100644 --- a/tests/utils/fixtures/setups/ansible/setup.py +++ b/tests/utils/fixtures/setups/ansible/setup.py @@ -53,7 +53,6 @@ def _find_symlinks(topdir, extension=""): def _cache_symlinks(symlink_data): - # explicit utf-8 for JSON with open(SYMLINK_CACHE, "w", encoding="utf-8") as f: json.dump(symlink_data, f) @@ -64,7 +63,6 @@ def _maintain_symlinks(symlink_type, base_path): # Try the cache first because going from git checkout to sdist is the # only time we know that we're going to cache correctly - # explicit utf-8 for JSON with open(SYMLINK_CACHE, "r", encoding="utf-8") as f: symlink_data = json.load(f) except (IOError, OSError) as e: @@ -141,7 +139,6 @@ def run(self): def read_file(file_name): """Read file and return its contents.""" - # explicit utf-8 for file such as requirements.txt with open(file_name, "r", encoding="utf-8") as f: return f.read() diff --git a/tests/utils/fixtures/setups/pyyaml/setup.py b/tests/utils/fixtures/setups/pyyaml/setup.py index 9c8de659531..c7d69d0d6f7 100644 --- a/tests/utils/fixtures/setups/pyyaml/setup.py +++ b/tests/utils/fixtures/setups/pyyaml/setup.py @@ -215,7 +215,6 @@ def build_extensions(self): def check_extension_availability(self, ext): cache = os.path.join(self.build_temp, "check_%s.out" % ext.feature_name) if not self.force and os.path.isfile(cache): - # explicit utf-8 data = open(cache, encoding="utf-8").read().strip() if data == "1": return True @@ -223,7 +222,6 @@ def check_extension_availability(self, ext): return False mkpath(self.build_temp) src = os.path.join(self.build_temp, "check_%s.c" % ext.feature_name) - # explicit utf-8 open(src, "w", encoding="utf-8").write(ext.feature_check) log.info("checking if %s is compilable" % ext.feature_name) try: @@ -245,7 +243,6 @@ def check_extension_availability(self, ext): ) log.warn(" specify the option --include-dirs or uncomment and") log.warn(" modify the parameter include_dirs in setup.cfg)") - # explicit utf-8 (to keep the style) open(cache, "w", encoding="utf-8").write("0\n") return False prog = "check_%s" % ext.feature_name diff --git a/tests/utils/fixtures/setups/sqlalchemy/setup.py b/tests/utils/fixtures/setups/sqlalchemy/setup.py index 34b450d8864..212aa57ff0c 100644 --- a/tests/utils/fixtures/setups/sqlalchemy/setup.py +++ b/tests/utils/fixtures/setups/sqlalchemy/setup.py @@ -112,14 +112,12 @@ def status_msgs(*msgs): print("*" * 75) -# explicit utf-8 for python source with open( os.path.join(os.path.dirname(__file__), "lib", "sqlalchemy", "__init__.py"), encoding="utf-8", ) as v_file: VERSION = re.compile(r".*__version__ = '(.*?)'", re.S).match(v_file.read()).group(1) -# explicit utf-8 for readme with open( os.path.join(os.path.dirname(__file__), "README.rst"), encoding="utf-8" ) as r_file: From 39e8eb9e4407bf15d797ae5a0ac4bf514c41145f Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Sun, 23 Jun 2019 21:25:23 +0200 Subject: [PATCH 20/22] rewert ansible.release import (keep order of vars unchanged) --- tests/utils/fixtures/setups/ansible/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utils/fixtures/setups/ansible/setup.py b/tests/utils/fixtures/setups/ansible/setup.py index 920c25148db..799b0cd45d6 100644 --- a/tests/utils/fixtures/setups/ansible/setup.py +++ b/tests/utils/fixtures/setups/ansible/setup.py @@ -25,7 +25,7 @@ sys.exit(1) sys.path.insert(0, os.path.abspath("lib")) -from ansible.release import __author__, __version__ +from ansible.release import __version__, __author__ SYMLINK_CACHE = "SYMLINK_CACHE.json" From a0097bee33ab3cd2dfc417a8a712d857b2d073c7 Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Mon, 24 Jun 2019 20:43:55 +0200 Subject: [PATCH 21/22] Revert to original content (as it comes from external project) --- tests/utils/fixtures/setups/ansible/setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/utils/fixtures/setups/ansible/setup.py b/tests/utils/fixtures/setups/ansible/setup.py index 799b0cd45d6..5d7d1f4ec60 100644 --- a/tests/utils/fixtures/setups/ansible/setup.py +++ b/tests/utils/fixtures/setups/ansible/setup.py @@ -6,6 +6,7 @@ import re import sys import warnings + from collections import defaultdict from distutils.command.build_scripts import build_scripts as BuildScripts from distutils.command.sdist import sdist as SDist @@ -53,7 +54,7 @@ def _find_symlinks(topdir, extension=""): def _cache_symlinks(symlink_data): - with open(SYMLINK_CACHE, "w", encoding="utf-8") as f: + with open(SYMLINK_CACHE, "w") as f: json.dump(symlink_data, f) @@ -62,8 +63,7 @@ def _maintain_symlinks(symlink_type, base_path): try: # Try the cache first because going from git checkout to sdist is the # only time we know that we're going to cache correctly - - with open(SYMLINK_CACHE, "r", encoding="utf-8") as f: + with open(SYMLINK_CACHE, "r") as f: symlink_data = json.load(f) except (IOError, OSError) as e: # IOError on py2, OSError on py3. Both have errno @@ -139,7 +139,7 @@ def run(self): def read_file(file_name): """Read file and return its contents.""" - with open(file_name, "r", encoding="utf-8") as f: + with open(file_name, "r") as f: return f.read() From 55398f1ed32d90270364edf3aa516f700d3f761c Mon Sep 17 00:00:00 2001 From: Jan Vlcinsky Date: Mon, 24 Jun 2019 23:23:15 +0200 Subject: [PATCH 22/22] all vendored setup.py files in fixtures reverted back to org --- .../fixtures/git/github.com/demo/no-version/setup.py | 4 +--- tests/utils/fixtures/setups/pyyaml/setup.py | 12 +++++------- tests/utils/fixtures/setups/sqlalchemy/setup.py | 7 ++----- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/tests/fixtures/git/github.com/demo/no-version/setup.py b/tests/fixtures/git/github.com/demo/no-version/setup.py index bb960775c26..4e1aea3034c 100644 --- a/tests/fixtures/git/github.com/demo/no-version/setup.py +++ b/tests/fixtures/git/github.com/demo/no-version/setup.py @@ -6,9 +6,7 @@ def read_version(): - with open( - os.path.join(os.path.dirname(__file__), "demo", "__init__.py"), encoding="utf-8" - ) as f: + with open(os.path.join(os.path.dirname(__file__), "demo", "__init__.py")) as f: for line in f: if line.startswith("__version__ = "): return ast.literal_eval(line[len("__version__ = ") :].strip()) diff --git a/tests/utils/fixtures/setups/pyyaml/setup.py b/tests/utils/fixtures/setups/pyyaml/setup.py index c7d69d0d6f7..5285386ba55 100644 --- a/tests/utils/fixtures/setups/pyyaml/setup.py +++ b/tests/utils/fixtures/setups/pyyaml/setup.py @@ -215,14 +215,14 @@ def build_extensions(self): def check_extension_availability(self, ext): cache = os.path.join(self.build_temp, "check_%s.out" % ext.feature_name) if not self.force and os.path.isfile(cache): - data = open(cache, encoding="utf-8").read().strip() + data = open(cache).read().strip() if data == "1": return True elif data == "0": return False mkpath(self.build_temp) src = os.path.join(self.build_temp, "check_%s.c" % ext.feature_name) - open(src, "w", encoding="utf-8").write(ext.feature_check) + open(src, "w").write(ext.feature_check) log.info("checking if %s is compilable" % ext.feature_name) try: [obj] = self.compiler.compile( @@ -243,7 +243,7 @@ def check_extension_availability(self, ext): ) log.warn(" specify the option --include-dirs or uncomment and") log.warn(" modify the parameter include_dirs in setup.cfg)") - open(cache, "w", encoding="utf-8").write("0\n") + open(cache, "w").write("0\n") return False prog = "check_%s" % ext.feature_name log.info("checking if %s is linkable" % ext.feature_name) @@ -268,11 +268,9 @@ def check_extension_availability(self, ext): ) log.warn(" specify the option --library-dirs or uncomment and") log.warn(" modify the parameter library_dirs in setup.cfg)") - # expplicit utf-8 (to keep the style) - open(cache, "w", encoding="utf-8").write("0\n") + open(cache, "w").write("0\n") return False - # expplicit utf-8 (to keep the style) - open(cache, "w", encoding="utf-8").write("1\n") + open(cache, "w").write("1\n") return True diff --git a/tests/utils/fixtures/setups/sqlalchemy/setup.py b/tests/utils/fixtures/setups/sqlalchemy/setup.py index 212aa57ff0c..8842a482d27 100644 --- a/tests/utils/fixtures/setups/sqlalchemy/setup.py +++ b/tests/utils/fixtures/setups/sqlalchemy/setup.py @@ -113,14 +113,11 @@ def status_msgs(*msgs): with open( - os.path.join(os.path.dirname(__file__), "lib", "sqlalchemy", "__init__.py"), - encoding="utf-8", + os.path.join(os.path.dirname(__file__), "lib", "sqlalchemy", "__init__.py") ) as v_file: VERSION = re.compile(r".*__version__ = '(.*?)'", re.S).match(v_file.read()).group(1) -with open( - os.path.join(os.path.dirname(__file__), "README.rst"), encoding="utf-8" -) as r_file: +with open(os.path.join(os.path.dirname(__file__), "README.rst")) as r_file: readme = r_file.read()