Skip to content

Commit d259e1d

Browse files
authored
Don’t inherit from object (#1084)
In python3 all classes inherit by default from object
1 parent 07f19b6 commit d259e1d

File tree

7 files changed

+61
-61
lines changed

7 files changed

+61
-61
lines changed

src/OpenSSL/SSL.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class SysCallError(Error):
293293
pass
294294

295295

296-
class _CallbackExceptionHelper(object):
296+
class _CallbackExceptionHelper:
297297
"""
298298
A base class for wrapper classes that allow for intelligent exception
299299
handling in OpenSSL callbacks.
@@ -657,7 +657,7 @@ def explode(*args, **kwargs):
657657
)
658658

659659

660-
class Session(object):
660+
class Session:
661661
"""
662662
A class representing an SSL session. A session defines certain connection
663663
parameters which may be re-used to speed up the setup of subsequent
@@ -669,7 +669,7 @@ class Session(object):
669669
pass
670670

671671

672-
class Context(object):
672+
class Context:
673673
"""
674674
:class:`OpenSSL.SSL.Context` instances define the parameters for setting
675675
up new SSL connections.
@@ -1588,7 +1588,7 @@ def set_cookie_verify_callback(self, callback):
15881588
)
15891589

15901590

1591-
class Connection(object):
1591+
class Connection:
15921592
_reverse_mapping = WeakValueDictionary()
15931593

15941594
def __init__(self, context, socket=None):

src/OpenSSL/crypto.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def _get_asn1_time(timestamp):
200200
return string_result
201201

202202

203-
class _X509NameInvalidator(object):
203+
class _X509NameInvalidator:
204204
def __init__(self):
205205
self._names = []
206206

@@ -213,7 +213,7 @@ def clear(self):
213213
del name._name
214214

215215

216-
class PKey(object):
216+
class PKey:
217217
"""
218218
A class representing an DSA or RSA public key or key pair.
219219
"""
@@ -392,7 +392,7 @@ def bits(self):
392392
return _lib.EVP_PKEY_bits(self._pkey)
393393

394394

395-
class _EllipticCurve(object):
395+
class _EllipticCurve:
396396
"""
397397
A representation of a supported elliptic curve.
398398
@@ -528,7 +528,7 @@ def get_elliptic_curve(name):
528528
raise ValueError("unknown curve name", name)
529529

530530

531-
class X509Name(object):
531+
class X509Name:
532532
"""
533533
An X.509 Distinguished Name.
534534
@@ -728,7 +728,7 @@ def get_components(self):
728728
return result
729729

730730

731-
class X509Extension(object):
731+
class X509Extension:
732732
"""
733733
An X.509 v3 certificate extension.
734734
"""
@@ -880,7 +880,7 @@ def get_data(self):
880880
return _ffi.buffer(char_result, result_length)[:]
881881

882882

883-
class X509Req(object):
883+
class X509Req:
884884
"""
885885
An X.509 certificate signing requests.
886886
"""
@@ -1092,7 +1092,7 @@ def verify(self, pkey):
10921092
return result
10931093

10941094

1095-
class X509(object):
1095+
class X509:
10961096
"""
10971097
An X.509 certificate.
10981098
"""
@@ -1566,7 +1566,7 @@ def get_extension(self, index):
15661566
return ext
15671567

15681568

1569-
class X509StoreFlags(object):
1569+
class X509StoreFlags:
15701570
"""
15711571
Flags for X509 verification, used to change the behavior of
15721572
:class:`X509Store`.
@@ -1589,7 +1589,7 @@ class X509StoreFlags(object):
15891589
CHECK_SS_SIGNATURE = _lib.X509_V_FLAG_CHECK_SS_SIGNATURE
15901590

15911591

1592-
class X509Store(object):
1592+
class X509Store:
15931593
"""
15941594
An X.509 store.
15951595
@@ -1755,7 +1755,7 @@ def __init__(self, message, certificate):
17551755
self.certificate = certificate
17561756

17571757

1758-
class X509StoreContext(object):
1758+
class X509StoreContext:
17591759
"""
17601760
An X.509 store context.
17611761
@@ -2080,7 +2080,7 @@ def dump_privatekey(type, pkey, cipher=None, passphrase=None):
20802080
return _bio_to_string(bio)
20812081

20822082

2083-
class Revoked(object):
2083+
class Revoked:
20842084
"""
20852085
A certificate revocation.
20862086
"""
@@ -2253,7 +2253,7 @@ def get_rev_date(self):
22532253
return _get_asn1_time(dt)
22542254

22552255

2256-
class CRL(object):
2256+
class CRL:
22572257
"""
22582258
A certificate revocation list.
22592259
"""
@@ -2475,7 +2475,7 @@ def export(
24752475
return dump_crl(type, self)
24762476

24772477

2478-
class PKCS7(object):
2478+
class PKCS7:
24792479
def type_is_signed(self):
24802480
"""
24812481
Check if this NID_pkcs7_signed object
@@ -2519,7 +2519,7 @@ def get_type_name(self):
25192519
return _ffi.string(string_type)
25202520

25212521

2522-
class PKCS12(object):
2522+
class PKCS12:
25232523
"""
25242524
A PKCS #12 archive.
25252525
"""
@@ -2700,7 +2700,7 @@ def export(self, passphrase=None, iter=2048, maciter=1):
27002700
return _bio_to_string(bio)
27012701

27022702

2703-
class NetscapeSPKI(object):
2703+
class NetscapeSPKI:
27042704
"""
27052705
A Netscape SPKI object.
27062706
"""
@@ -2790,7 +2790,7 @@ def set_pubkey(self, pkey):
27902790
_openssl_assert(set_result == 1)
27912791

27922792

2793-
class _PassphraseHelper(object):
2793+
class _PassphraseHelper:
27942794
def __init__(self, type, passphrase, more_args=False, truncate=False):
27952795
if type != FILETYPE_PEM and passphrase is not None:
27962796
raise ValueError(

tests/test_crypto.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ def x509_data():
809809
yield pkey, x509
810810

811811

812-
class TestX509Ext(object):
812+
class TestX509Ext:
813813
"""
814814
Tests for `OpenSSL.crypto.X509Extension`.
815815
"""
@@ -1008,7 +1008,7 @@ def test_invalid_issuer(self, bad_obj):
10081008
)
10091009

10101010

1011-
class TestPKey(object):
1011+
class TestPKey:
10121012
"""
10131013
Tests for `OpenSSL.crypto.PKey`.
10141014
"""
@@ -1222,7 +1222,7 @@ def key(attr):
12221222
return name
12231223

12241224

1225-
class TestX509Name(object):
1225+
class TestX509Name:
12261226
"""
12271227
Unit tests for `OpenSSL.crypto.X509Name`.
12281228
"""
@@ -2224,7 +2224,7 @@ def test_convert_to_cryptography_key(self):
22242224
assert crypto_cert.version.value == cert.get_version()
22252225

22262226

2227-
class TestX509Store(object):
2227+
class TestX509Store:
22282228
"""
22292229
Test for `OpenSSL.crypto.X509Store`.
22302230
"""
@@ -2295,7 +2295,7 @@ def test_add_cert_accepts_duplicate(self):
22952295
def test_load_locations_parameters(
22962296
self, cafile, capath, call_cafile, call_capath, monkeypatch
22972297
):
2298-
class LibMock(object):
2298+
class LibMock:
22992299
def load_locations(self, store, cafile, capath):
23002300
self.cafile = cafile
23012301
self.capath = capath
@@ -2326,7 +2326,7 @@ def test_load_locations_raises_error_on_failure(self, tmpdir):
23262326
store.load_locations(cafile=str(invalid_ca_file))
23272327

23282328

2329-
class TestPKCS12(object):
2329+
class TestPKCS12:
23302330
"""
23312331
Test for `OpenSSL.crypto.PKCS12` and `OpenSSL.crypto.load_pkcs12`.
23322332
"""
@@ -2802,7 +2802,7 @@ def _runopenssl(pem, *args):
28022802
return output
28032803

28042804

2805-
class TestLoadPublicKey(object):
2805+
class TestLoadPublicKey:
28062806
"""
28072807
Tests for :func:`load_publickey`.
28082808
"""
@@ -2842,7 +2842,7 @@ def test_tolerates_unicode_strings(self):
28422842
assert dumped_pem == cleartextPublicKeyPEM
28432843

28442844

2845-
class TestFunction(object):
2845+
class TestFunction:
28462846
"""
28472847
Tests for free-functions in the `OpenSSL.crypto` module.
28482848
"""
@@ -3263,7 +3263,7 @@ def test_load_pkcs7_type_invalid(self):
32633263
load_pkcs7_data(object(), b"foo")
32643264

32653265

3266-
class TestLoadCertificate(object):
3266+
class TestLoadCertificate:
32673267
"""
32683268
Tests for `load_certificate_request`.
32693269
"""
@@ -3287,7 +3287,7 @@ def test_bad_certificate(self):
32873287
load_certificate(FILETYPE_ASN1, b"lol")
32883288

32893289

3290-
class TestPKCS7(object):
3290+
class TestPKCS7:
32913291
"""
32923292
Tests for `PKCS7`.
32933293
"""
@@ -3387,7 +3387,7 @@ def test_b64_encode(self):
33873387
assert isinstance(blob, bytes)
33883388

33893389

3390-
class TestRevoked(object):
3390+
class TestRevoked:
33913391
"""
33923392
Tests for `OpenSSL.crypto.Revoked`.
33933393
"""
@@ -3497,7 +3497,7 @@ def test_set_reason_invalid_reason(self):
34973497
revoked.set_reason(b"blue")
34983498

34993499

3500-
class TestCRL(object):
3500+
class TestCRL:
35013501
"""
35023502
Tests for `OpenSSL.crypto.CRL`.
35033503
"""
@@ -3858,7 +3858,7 @@ def test_convert_to_cryptography_key(self):
38583858
assert isinstance(crypto_crl, x509.CertificateRevocationList)
38593859

38603860

3861-
class TestX509StoreContext(object):
3861+
class TestX509StoreContext:
38623862
"""
38633863
Tests for `OpenSSL.crypto.X509StoreContext`.
38643864
"""
@@ -4226,7 +4226,7 @@ def test_verify_failure_with_empty_ca_directory(self, tmpdir):
42264226
assert exc.value.args[0][2] == "unable to get local issuer certificate"
42274227

42284228

4229-
class TestSignVerify(object):
4229+
class TestSignVerify:
42304230
"""
42314231
Tests for `OpenSSL.crypto.sign` and `OpenSSL.crypto.verify`.
42324232
"""
@@ -4348,7 +4348,7 @@ def test_sign_with_large_key(self):
43484348
sign(priv_key, content, "sha256")
43494349

43504350

4351-
class TestEllipticCurve(object):
4351+
class TestEllipticCurve:
43524352
"""
43534353
Tests for `_EllipticCurve`, `get_elliptic_curve`, and
43544354
`get_elliptic_curves`.
@@ -4399,7 +4399,7 @@ def test_to_EC_KEY(self):
43994399
curve._to_EC_KEY()
44004400

44014401

4402-
class EllipticCurveFactory(object):
4402+
class EllipticCurveFactory:
44034403
"""
44044404
A helper to get the names of two curves.
44054405
"""
@@ -4434,7 +4434,7 @@ def anotherInstance(self):
44344434
return get_elliptic_curve(self.curve_factory.another_curve_name)
44354435

44364436

4437-
class TestEllipticCurveHash(object):
4437+
class TestEllipticCurveHash:
44384438
"""
44394439
Tests for `_EllipticCurve`'s implementation of hashing (thus use as
44404440
an item in a `dict` or `set`).

tests/test_rand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from OpenSSL import rand
1111

1212

13-
class TestRand(object):
13+
class TestRand:
1414
@pytest.mark.parametrize("args", [(b"foo", None), (None, 3)])
1515
def test_add_wrong_args(self, args):
1616
"""

0 commit comments

Comments
 (0)