Skip to content

Commit

Permalink
Remove API deprecated in 1.6, clean up the legacy deprecations (#3468)
Browse files Browse the repository at this point in the history
* Remove API deprecated in 1.6, clean up the legacy deprecations

* flake8, unused import
  • Loading branch information
alex authored and reaperhulk committed Mar 21, 2017
1 parent fd2b27a commit a783c57
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/cryptography/hazmat/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _available_backends():
import pkg_resources

entry_point_backends = [
# DeprecatedIn16
# PersistentlyDeprecated
# setuptools 11.3 deprecated support for the require parameter to
# load(), and introduced the new resolve() method instead.
# We previously removed this fallback, but users are having issues
Expand Down
2 changes: 1 addition & 1 deletion src/cryptography/hazmat/backends/openssl/x509.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def version(self):
def serial(self):
warnings.warn(
"Certificate serial is deprecated, use serial_number instead.",
utils.DeprecatedIn14,
utils.PersistentlyDeprecated,
stacklevel=2
)
return self.serial_number
Expand Down
4 changes: 2 additions & 2 deletions src/cryptography/hazmat/primitives/asymmetric/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def decode_rfc6979_signature(signature):
warnings.warn(
"decode_rfc6979_signature is deprecated and will "
"be removed in a future version, use decode_dss_signature instead.",
utils.DeprecatedIn10,
utils.PersistentlyDeprecated,
stacklevel=2
)
return decode_dss_signature(signature)
Expand All @@ -33,7 +33,7 @@ def encode_rfc6979_signature(r, s):
warnings.warn(
"encode_rfc6979_signature is deprecated and will "
"be removed in a future version, use encode_dss_signature instead.",
utils.DeprecatedIn10,
utils.PersistentlyDeprecated,
stacklevel=2
)
return encode_dss_signature(r, s)
Expand Down
10 changes: 4 additions & 6 deletions src/cryptography/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
from packaging.version import parse


# the functions deprecated in 1.0 and 1.4 are on an arbitrarily extended
# deprecation cycle and should not be removed until we agree on when that cycle
# ends.
DeprecatedIn10 = DeprecationWarning
DeprecatedIn14 = DeprecationWarning
DeprecatedIn16 = DeprecationWarning
# Several APIs were deprecated with no specific end-of-life date because of the
# ubiquity of their use. They should not be removed until we agree on when that
# cycle ends.
PersistentlyDeprecated = DeprecationWarning


def read_only_property(name):
Expand Down
14 changes: 2 additions & 12 deletions src/cryptography/x509/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import datetime
import hashlib
import ipaddress
import warnings
from enum import Enum

from asn1crypto.keys import PublicKeyInfo
Expand All @@ -20,7 +19,7 @@
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePublicKey
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicKey
from cryptography.x509.general_name import GeneralName, IPAddress, OtherName
from cryptography.x509.name import Name, RelativeDistinguishedName
from cryptography.x509.name import RelativeDistinguishedName
from cryptography.x509.oid import (
CRLEntryExtensionOID, ExtensionOID, ObjectIdentifier
)
Expand Down Expand Up @@ -421,16 +420,7 @@ def __init__(self, full_name, relative_name, reasons, crl_issuer):
)

if relative_name:
if isinstance(relative_name, Name):
warnings.warn(
"relative_name=<Name> is deprecated and will "
"be removed in a future version; use "
"<RelativeDistinguishedName> instead.",
utils.DeprecatedIn16,
stacklevel=2
)
relative_name = RelativeDistinguishedName(relative_name)
elif not isinstance(relative_name, RelativeDistinguishedName):
if not isinstance(relative_name, RelativeDistinguishedName):
raise TypeError(
"relative_name must be a RelativeDistinguishedName"
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_x509.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def test_cert_serial_number(self, backend):
)

with warnings.catch_warnings():
warnings.simplefilter("always", utils.DeprecatedIn10)
warnings.simplefilter("always", utils.PersistentlyDeprecated)
assert cert.serial == 2
assert cert.serial_number == 2

Expand All @@ -533,7 +533,7 @@ def test_cert_serial_warning(self, backend):
)

with warnings.catch_warnings():
warnings.simplefilter("always", utils.DeprecatedIn10)
warnings.simplefilter("always", utils.PersistentlyDeprecated)
with pytest.deprecated_call():
cert.serial

Expand Down
11 changes: 0 additions & 11 deletions tests/test_x509_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -3003,17 +3003,6 @@ def test_distribution_point_full_and_relative_not_none(self):
with pytest.raises(ValueError):
x509.DistributionPoint("data", "notname", None, None)

def test_relative_name_name_value_deprecated(self):
with pytest.deprecated_call():
x509.DistributionPoint(
None,
x509.Name([
x509.NameAttribute(NameOID.COMMON_NAME, u"myCN")
]),
None,
None
)

def test_crl_issuer_not_general_names(self):
with pytest.raises(TypeError):
x509.DistributionPoint(None, None, None, ["notgn"])
Expand Down

0 comments on commit a783c57

Please sign in to comment.