Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Deprecate support forstring named-parameter in hash functions constructors #134978

Closed
Assignees
picnixz
Labels
extension-modulesC modules in the Modules dirtype-featureA feature request or enhancement
@picnixz

Description

@picnixz

Feature or enhancement

This is a follow-up to#134696. Afterc6e63d9, it's now possible to use the following forms:

  • hashlib.new(name, data)
  • hashlib.new(name, data=...)
  • hashlib.new(name, string=...)

and, taking MD5 as an example,hashlib.md5(data),hashlib.md5(data=...) andhashlib.md5(string=...).

In thedocs we only expose the following signatures:

hashlib.new(name, [data, ]*, usedforsecurity=True)hashlib.md5([data, ]*, usedforsecurity=True)

So, it would make sense to remove support forstring=.... Ideally, I want to make it positional-only, but I don't think it's worth the shot and it's too much for a breaking change.

Note that we could also deprecatedata itself because originally,PEP-247 andPEP-452 were usingstring and notdata, but this is probably confusing as the PEP says:

Although the parameter is called ‘string’, hashing objects operate on 8-bit data only. Both ‘key’ and ‘string’ must be a bytes-like object (bytes, bytearray…).

I assume that the docs decided to use 'data' to remove this ambiguity as 'data' is more common for bytes-like objects.

cc@gpshead

Linked PRs

Metadata

Metadata

Assignees

Labels

extension-modulesC modules in the Modules dirtype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp