bpo-33729: Fix issues with arguments parsing in hashlib. (GH-8346) · python/cpython@f1d36d8 (original) (raw)

`@@ -47,10 +47,10 @@ typedef struct {

`

47

47

`#include "clinic/blake2b_impl.c.h"

`

48

48

``

49

49

`/*[clinic input]

`

50

``

`-

module _blake2b

`

51

``

`-

class _blake2b.blake2b "BLAKE2bObject *" "&PyBlake2_BLAKE2bType"

`

``

50

`+

module _blake2

`

``

51

`+

class _blake2.blake2b "BLAKE2bObject *" "&PyBlake2_BLAKE2bType"

`

52

52

`[clinic start generated code]*/

`

53

``

`-

/[clinic end generated code: output=da39a3ee5e6b4b0d input=6893358c6622aecf]/

`

``

53

`+

/[clinic end generated code: output=da39a3ee5e6b4b0d input=d47b0527b39c673f]/

`

54

54

``

55

55

``

56

56

`static BLAKE2bObject *

`

`@@ -66,13 +66,14 @@ new_BLAKE2bObject(PyTypeObject *type)

`

66

66

``

67

67

`/*[clinic input]

`

68

68

`@classmethod

`

69

``

`-

_blake2b.blake2b.new as py_blake2b_new

`

70

``

`-

string as data: object = NULL

`

``

69

`+

_blake2.blake2b.new as py_blake2b_new

`

``

70

`+

data: object(c_default="NULL") = b''

`

``

71

`+

/

`

71

72

` *

`

72

``

`-

digest_size: int(c_default="BLAKE2B_OUTBYTES") = _blake2b.blake2b.MAX_DIGEST_SIZE

`

73

``

`-

key: Py_buffer = None

`

74

``

`-

salt: Py_buffer = None

`

75

``

`-

person: Py_buffer = None

`

``

73

`+

digest_size: int(c_default="BLAKE2B_OUTBYTES") = _blake2.blake2b.MAX_DIGEST_SIZE

`

``

74

`+

key: Py_buffer(c_default="NULL", py_default="b''") = None

`

``

75

`+

salt: Py_buffer(c_default="NULL", py_default="b''") = None

`

``

76

`+

person: Py_buffer(c_default="NULL", py_default="b''") = None

`

76

77

` fanout: int = 1

`

77

78

` depth: int = 1

`

78

79

` leaf_size: unsigned_long = 0

`

`@@ -90,7 +91,7 @@ py_blake2b_new_impl(PyTypeObject *type, PyObject *data, int digest_size,

`

90

91

`int fanout, int depth, unsigned long leaf_size,

`

91

92

`unsigned long long node_offset, int node_depth,

`

92

93

`int inner_size, int last_node)

`

93

``

`-

/[clinic end generated code: output=65e732c66c2297a0 input=75ab5196b695adee]/

`

``

94

`+

/[clinic end generated code: output=65e732c66c2297a0 input=82be35a4e6a9daa2]/

`

94

95

`{

`

95

96

`BLAKE2bObject *self = NULL;

`

96

97

`Py_buffer buf;

`

`@@ -237,14 +238,14 @@ py_blake2b_new_impl(PyTypeObject *type, PyObject *data, int digest_size,

`

237

238

`}

`

238

239

``

239

240

`/*[clinic input]

`

240

``

`-

_blake2b.blake2b.copy

`

``

241

`+

_blake2.blake2b.copy

`

241

242

``

242

243

`Return a copy of the hash object.

`

243

244

`[clinic start generated code]*/

`

244

245

``

245

246

`static PyObject *

`

246

``

`-

_blake2b_blake2b_copy_impl(BLAKE2bObject *self)

`

247

``

`-

/[clinic end generated code: output=c89cd33550ab1543 input=4c9c319f18f10747]/

`

``

247

`+

_blake2_blake2b_copy_impl(BLAKE2bObject *self)

`

``

248

`+

/[clinic end generated code: output=ff6acee5f93656ae input=e383c2d199fd8a2e]/

`

248

249

`{

`

249

250

`BLAKE2bObject *cpy;

`

250

251

``

`@@ -259,21 +260,21 @@ _blake2b_blake2b_copy_impl(BLAKE2bObject *self)

`

259

260

`}

`

260

261

``

261

262

`/*[clinic input]

`

262

``

`-

_blake2b.blake2b.update

`

``

263

`+

_blake2.blake2b.update

`

263

264

``

264

``

`-

obj: object

`

``

265

`+

data: object

`

265

266

` /

`

266

267

``

267

``

`-

Update this hash object's state with the provided string.

`

``

268

`+

Update this hash object's state with the provided bytes-like object.

`

268

269

`[clinic start generated code]*/

`

269

270

``

270

271

`static PyObject *

`

271

``

`-

_blake2b_blake2b_update(BLAKE2bObject *self, PyObject *obj)

`

272

``

`-

/[clinic end generated code: output=a888f07c4cddbe94 input=3ecb8c13ee4260f2]/

`

``

272

`+

_blake2_blake2b_update(BLAKE2bObject *self, PyObject *data)

`

``

273

`+

/[clinic end generated code: output=010dfcbe22654359 input=ffc4aa6a6a225d31]/

`

273

274

`{

`

274

275

`Py_buffer buf;

`

275

276

``

276

``

`-

GET_BUFFER_VIEW_OR_ERROUT(obj, &buf);

`

``

277

`+

GET_BUFFER_VIEW_OR_ERROUT(data, &buf);

`

277

278

``

278

279

`if (self->lock == NULL && buf.len >= HASHLIB_GIL_MINSIZE)

`

279

280

`self->lock = PyThread_allocate_lock();

`

`@@ -293,14 +294,14 @@ _blake2b_blake2b_update(BLAKE2bObject *self, PyObject *obj)

`

293

294

`}

`

294

295

``

295

296

`/*[clinic input]

`

296

``

`-

_blake2b.blake2b.digest

`

``

297

`+

_blake2.blake2b.digest

`

297

298

``

298

``

`-

Return the digest value as a string of binary data.

`

``

299

`+

Return the digest value as a bytes object.

`

299

300

`[clinic start generated code]*/

`

300

301

``

301

302

`static PyObject *

`

302

``

`-

_blake2b_blake2b_digest_impl(BLAKE2bObject *self)

`

303

``

`-

/[clinic end generated code: output=b13a79360d984740 input=ac2fa462ebb1b9c7]/

`

``

303

`+

_blake2_blake2b_digest_impl(BLAKE2bObject *self)

`

``

304

`+

/[clinic end generated code: output=a5864660f4bfc61a input=7d21659e9c5fff02]/

`

304

305

`{

`

305

306

`uint8_t digest[BLAKE2B_OUTBYTES];

`

306

307

`blake2b_state state_cpy;

`

`@@ -314,14 +315,14 @@ _blake2b_blake2b_digest_impl(BLAKE2bObject *self)

`

314

315

`}

`

315

316

``

316

317

`/*[clinic input]

`

317

``

`-

_blake2b.blake2b.hexdigest

`

``

318

`+

_blake2.blake2b.hexdigest

`

318

319

``

319

320

`Return the digest value as a string of hexadecimal digits.

`

320

321

`[clinic start generated code]*/

`

321

322

``

322

323

`static PyObject *

`

323

``

`-

_blake2b_blake2b_hexdigest_impl(BLAKE2bObject *self)

`

324

``

`-

/[clinic end generated code: output=6a503611715b24bd input=d58f0b2f37812e33]/

`

``

324

`+

_blake2_blake2b_hexdigest_impl(BLAKE2bObject *self)

`

``

325

`+

/[clinic end generated code: output=b5598a87d8794a60 input=76930f6946351f56]/

`

325

326

`{

`

326

327

`uint8_t digest[BLAKE2B_OUTBYTES];

`

327

328

`blake2b_state state_cpy;

`

`@@ -335,10 +336,10 @@ _blake2b_blake2b_hexdigest_impl(BLAKE2bObject *self)

`

335

336

``

336

337

``

337

338

`static PyMethodDef py_blake2b_methods[] = {

`

338

``

`-

_BLAKE2B_BLAKE2B_COPY_METHODDEF

`

339

``

`-

_BLAKE2B_BLAKE2B_DIGEST_METHODDEF

`

340

``

`-

_BLAKE2B_BLAKE2B_HEXDIGEST_METHODDEF

`

341

``

`-

_BLAKE2B_BLAKE2B_UPDATE_METHODDEF

`

``

339

`+

_BLAKE2_BLAKE2B_COPY_METHODDEF

`

``

340

`+

_BLAKE2_BLAKE2B_DIGEST_METHODDEF

`

``

341

`+

_BLAKE2_BLAKE2B_HEXDIGEST_METHODDEF

`

``

342

`+

_BLAKE2_BLAKE2B_UPDATE_METHODDEF

`

342

343

` {NULL, NULL}

`

343

344

`};

`

344

345

``