diff --git a/codebuild/py38/awses_local.yml b/codebuild/py38/awses_local.yml index fe84d714d..b221abe72 100644 --- a/codebuild/py38/awses_local.yml +++ b/codebuild/py38/awses_local.yml @@ -20,6 +20,8 @@ phases: python: latest build: commands: - - pip install tox + - pyenv install 3.8.6 + - pyenv local 3.8.6 + - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py38/examples.yml b/codebuild/py38/examples.yml index 180c606f4..c9a9f9a7a 100644 --- a/codebuild/py38/examples.yml +++ b/codebuild/py38/examples.yml @@ -18,5 +18,7 @@ phases: python: latest build: commands: - - pip install tox + - pyenv install 3.8.6 + - pyenv local 3.8.6 + - pip install tox tox-pyenv - tox diff --git a/codebuild/py38/integ.yml b/codebuild/py38/integ.yml index 6af55e839..31cbb7d43 100644 --- a/codebuild/py38/integ.yml +++ b/codebuild/py38/integ.yml @@ -18,5 +18,7 @@ phases: python: latest build: commands: - - pip install tox + - pyenv install 3.8.6 + - pyenv local 3.8.6 + - pip install tox tox-pyenv - tox diff --git a/decrypt_oracle/setup.py b/decrypt_oracle/setup.py index 72c56dd04..c56d64911 100644 --- a/decrypt_oracle/setup.py +++ b/decrypt_oracle/setup.py @@ -10,7 +10,7 @@ def read(*args): """Read complete file contents.""" - return open(os.path.join(HERE, *args)).read() # pylint: disable=consider-using-with + return open(os.path.join(HERE, *args), encoding="utf-8").read() # pylint: disable=consider-using-with def get_version(): diff --git a/decrypt_oracle/test/integration/integration_test_utils.py b/decrypt_oracle/test/integration/integration_test_utils.py index eeb6219ac..c03b7f440 100644 --- a/decrypt_oracle/test/integration/integration_test_utils.py +++ b/decrypt_oracle/test/integration/integration_test_utils.py @@ -100,7 +100,7 @@ def test_vectors_filename() -> Text: def all_test_vectors() -> Iterable[Any]: """Collect and iterate through all test vectors.""" - with open(test_vectors_filename(), "r") as vectors_file: + with open(test_vectors_filename(), "r", encoding="utf-8") as vectors_file: raw_vectors = json.load(vectors_file) for vector in raw_vectors: diff --git a/examples/src/one_kms_cmk_streaming_data.py b/examples/src/one_kms_cmk_streaming_data.py index 88eb4eb5c..f4e5ce476 100644 --- a/examples/src/one_kms_cmk_streaming_data.py +++ b/examples/src/one_kms_cmk_streaming_data.py @@ -25,7 +25,7 @@ def encrypt_decrypt_stream(key_arn, source_plaintext_filename, botocore_session= :param botocore_session: existing botocore session instance :type botocore_session: botocore.session.Session """ - kwargs = dict() + kwargs = {} kwargs["key_ids"] = [key_arn] diff --git a/setup.py b/setup.py index a755b75ad..bfe48b091 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ def read(*args): """Reads complete file contents.""" - return open(os.path.join(HERE, *args)).read() # pylint: disable=consider-using-with + return open(os.path.join(HERE, *args), encoding="utf-8").read() # pylint: disable=consider-using-with def get_version(): diff --git a/src/aws_encryption_sdk/internal/formatting/deserialize.py b/src/aws_encryption_sdk/internal/formatting/deserialize.py index d2cfb1095..b06b5ba11 100644 --- a/src/aws_encryption_sdk/internal/formatting/deserialize.py +++ b/src/aws_encryption_sdk/internal/formatting/deserialize.py @@ -344,7 +344,7 @@ def deserialize_header(stream, max_encrypted_data_keys=None): tee_stream = TeeStream(stream, tee) (version_id,) = unpack_values(">B", tee_stream) version = _verified_version_from_id(version_id) - header = dict() + header = {} header["version"] = version if version == SerializationVersion.V1: diff --git a/test/functional/test_f_xcompat.py b/test/functional/test_f_xcompat.py index e87082503..790724367 100644 --- a/test/functional/test_f_xcompat.py +++ b/test/functional/test_f_xcompat.py @@ -126,7 +126,7 @@ def _generate_test_cases(): # noqa=C901 # Make no test cases if the ciphertext file is not found return [] - with open(ciphertext_manifest_path) as f: + with open(ciphertext_manifest_path, encoding="utf-8") as f: ciphertext_manifest = json.load(f) _test_cases = [] diff --git a/test/integration/test_i_xcompat_kms.py b/test/integration/test_i_xcompat_kms.py index b6f22a3ff..7cfeee111 100644 --- a/test/integration/test_i_xcompat_kms.py +++ b/test/integration/test_i_xcompat_kms.py @@ -48,7 +48,7 @@ def _generate_test_cases(): # Make no test cases if the ciphertext file is not found return [] - with open(ciphertext_manifest_path) as f: + with open(ciphertext_manifest_path, encoding="utf-8") as f: ciphertext_manifest = json.load(f) _test_cases = [] @@ -69,9 +69,9 @@ def _generate_test_cases(): @pytest.mark.parametrize("plaintext_filename, ciphertext_filename", _generate_test_cases()) def test_decrypt_from_file(plaintext_filename, ciphertext_filename): """Tests decrypt from known good files.""" - with open(ciphertext_filename, "rb") as infile: + with open(ciphertext_filename, "rb", encoding="utf-8") as infile: ciphertext = infile.read() - with open(plaintext_filename, "rb") as infile: + with open(plaintext_filename, "rb", encoding="utf-8") as infile: plaintext = infile.read() decrypted_ciphertext, _header = aws_encryption_sdk.decrypt( source=ciphertext, key_provider=setup_kms_master_key_provider() diff --git a/test/integration/test_kat_commitment.py b/test/integration/test_kat_commitment.py index fa97600f0..e72277787 100644 --- a/test/integration/test_kat_commitment.py +++ b/test/integration/test_kat_commitment.py @@ -50,7 +50,7 @@ def _file_root(): base_dir = os.path.join(root_dir, "test", "resources") file_path = os.path.join(base_dir, FILE_NAME) -test_str = open(file_path, "r").read() # pylint: disable=consider-using-with +test_str = open(file_path, "r", encoding="utf-8").read() # pylint: disable=consider-using-with test_json = json.loads(test_str) kat_tests = test_json["tests"] diff --git a/test/unit/test_encryption_client.py b/test/unit/test_encryption_client.py index f463b04f1..db2ca1c4c 100644 --- a/test/unit/test_encryption_client.py +++ b/test/unit/test_encryption_client.py @@ -59,7 +59,7 @@ def test_client_encrypt(mocker): commitment_policy=CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT, max_encrypted_data_keys=3 ) - kwargs = dict() + kwargs = {} kwargs["source"] = b"plaintext" kwargs["materials_manager"] = cmm client.encrypt(**kwargs) @@ -77,7 +77,7 @@ def test_client_decrypt(mocker): commitment_policy=CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT, max_encrypted_data_keys=3 ) - kwargs = dict() + kwargs = {} kwargs["source"] = b"ciphertext" kwargs["materials_manager"] = cmm client.decrypt(**kwargs) @@ -94,7 +94,7 @@ def test_client_stream_encrypt(mocker, mode_string): cmm = MagicMock(__class__=CryptoMaterialsManager) client = aws_encryption_sdk.EncryptionSDKClient(commitment_policy=CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT) - kwargs = dict() + kwargs = {} kwargs["mode"] = mode_string kwargs["source"] = b"plaintext" kwargs["materials_manager"] = cmm @@ -113,7 +113,7 @@ def test_client_stream_decrypt(mocker, mode_string): cmm = MagicMock(__class__=CryptoMaterialsManager) client = aws_encryption_sdk.EncryptionSDKClient(commitment_policy=CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT) - kwargs = dict() + kwargs = {} kwargs["mode"] = mode_string kwargs["source"] = b"ciphertext" kwargs["materials_manager"] = cmm @@ -132,7 +132,7 @@ def test_client_bad_kwargs(mocker, method, key): mocker.patch.object(aws_encryption_sdk, "StreamEncryptor") cmm = MagicMock(__class__=CryptoMaterialsManager) - kwargs = dict() + kwargs = {} kwargs[key] = "foobar" kwargs["source"] = b"ciphertext" kwargs["materials_manager"] = cmm diff --git a/test/unit/test_material_managers.py b/test/unit/test_material_managers.py index 22a7a753e..2d892bd36 100644 --- a/test/unit/test_material_managers.py +++ b/test/unit/test_material_managers.py @@ -68,7 +68,7 @@ (EncryptionMaterials, dict(data_encryption_key=None)), (EncryptionMaterials, dict(encrypted_data_keys=None)), (EncryptionMaterials, dict(encryption_context=None)), - (EncryptionMaterials, dict(signing_key=u"not bytes or None")), + (EncryptionMaterials, dict(signing_key="not bytes or None")), (DecryptionMaterialsRequest, dict(algorithm=None)), (DecryptionMaterialsRequest, dict(encrypted_data_keys=None)), (DecryptionMaterialsRequest, dict(encryption_context=None)), diff --git a/test/unit/test_util_str_ops.py b/test/unit/test_util_str_ops.py index 1778bc4a0..5a6ef2546 100644 --- a/test/unit/test_util_str_ops.py +++ b/test/unit/test_util_str_ops.py @@ -39,17 +39,17 @@ def test_to_bytes_bytes2bytes(self): assert test == b"\x3a\x00\x99" def test_to_str_bytes2unicode(self): - test = aws_encryption_sdk.internal.str_ops.to_str(codecs.encode(u"Предисловие", "utf-8")) - assert test == u"Предисловие" + test = aws_encryption_sdk.internal.str_ops.to_str(codecs.encode("Предисловие", "utf-8")) + assert test == "Предисловие" def test_to_str_unicode2unicode(self): - test = aws_encryption_sdk.internal.str_ops.to_str(u"Предисловие") - assert test == u"Предисловие" + test = aws_encryption_sdk.internal.str_ops.to_str("Предисловие") + assert test == "Предисловие" def test_to_str_unicode2bytes(self): - test = aws_encryption_sdk.internal.str_ops.to_bytes(u"Предисловие") - assert test == codecs.encode(u"Предисловие", "utf-8") + test = aws_encryption_sdk.internal.str_ops.to_bytes("Предисловие") + assert test == codecs.encode("Предисловие", "utf-8") def test_to_bytes_utf82utf8(self): - test = aws_encryption_sdk.internal.str_ops.to_bytes(codecs.encode(u"Предисловие", "utf-8")) - assert test == codecs.encode(u"Предисловие", "utf-8") + test = aws_encryption_sdk.internal.str_ops.to_bytes(codecs.encode("Предисловие", "utf-8")) + assert test == codecs.encode("Предисловие", "utf-8") diff --git a/test/unit/test_utils.py b/test/unit/test_utils.py index 72f98e731..c6d565108 100644 --- a/test/unit/test_utils.py +++ b/test/unit/test_utils.py @@ -35,7 +35,7 @@ def test_prep_stream_data_passthrough(): assert_prepped_stream_identity(test, io.BytesIO) -@pytest.mark.parametrize("source", (u"some unicode data ловие", b"\x00\x01\x02")) +@pytest.mark.parametrize("source", ("some unicode data ловие", b"\x00\x01\x02")) def test_prep_stream_data_wrap(source): test = aws_encryption_sdk.internal.utils.prep_stream_data(source) diff --git a/test_vector_handlers/setup.py b/test_vector_handlers/setup.py index 661ea722c..9a89fb698 100644 --- a/test_vector_handlers/setup.py +++ b/test_vector_handlers/setup.py @@ -10,7 +10,7 @@ def read(*args): """Read complete file contents.""" - return open(os.path.join(HERE, *args)).read() # pylint: disable=consider-using-with + return open(os.path.join(HERE, *args), encoding="utf-8").read() # pylint: disable=consider-using-with def get_version():