GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-85283: Build md5 extension with limited C API by vstinner · Pull Request #110967 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Oct 17, 2023 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Replace _Py_strhex() with few lines of code.
  • Replace _PyType_GetModuleState() with PyType_GetModuleState().
  • Issue: [C API] Convert a few stdlib extensions to the limited C API (PEP 384) #85283

📚 Documentation preview 📚: https://cpython-previews--110967.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
vstinner requested a review from tiran as a code owner October 17, 2023 09:04
@bedevere-app bedevere-app Bot mentioned this pull request Oct 17, 2023
[C API] Convert a few stdlib extensions to the limited C API (PEP 384) #85283
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 17, 2023
@vstinner

vstinner commented Oct 17, 2023

Copy link
Copy Markdown
Member Author

Replace _Py_strhex() with few lines of code.

For now, I prefer to not add such function to the public C API, since users may want many variants:

  • Uppercase letters
  • Space separator
  • Get a bytes object instead of a str object

See Include/internal/pycore_strhex.h: there are 4 functions with different arguments.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner force-pushed the limited_md5 branch from e5a12f5 to 91fad9c Compare October 17, 2023 10:29
@vstinner
pythongh-85283: Build md5 extension with limited C API
fcad07b
* Replace _Py_strhex() with few lines of code.
* Replace _PyType_GetModuleState() with PyType_GetModuleState().
* Fix make check-c-globals
@vstinner
vstinner force-pushed the limited_md5 branch from 91fad9c to fcad07b Compare October 17, 2023 10:29
@vstinner
vstinner enabled auto-merge (squash) October 17, 2023 10:30
@vstinner

vstinner commented Oct 17, 2023

Copy link
Copy Markdown
Member Author

The _md5 extension is not used in practice:

vstinner@mona$ ./python
Python 3.13.0a1+ (heads/limited_md5-dirty:417055ae80, Oct 17 2023, 12:28:44) [GCC 13.2.1 20231011 (Red Hat 13.2.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import _md5
>>> h1=_md5.md5(b'Python')
>>> type(h1).__module__
'_md5'
>>> import hashlib
>>> h2=hashlib.new('md5', b'Python')
>>> type(h2).__module__
'_hashlib'
>>> h1.digest() == h2.digest()
True

hashlib uses the OpenSSL implementation of MD5. The _md5 extension is only used when OpenSSL is missing, which should not be the case on Linux, Windows, macOS, FreeBSD, etc.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner merged commit 4dba0a6 into python:main Oct 17, 2023
@vstinner
vstinner deleted the limited_md5 branch October 17, 2023 10:57
@bedevere-app bedevere-app Bot removed the awaiting core review label Oct 17, 2023
@vstinner vstinner mentioned this pull request Oct 17, 2023
gh-85283: Fix Argument Clinic for md5 extension #110976
Merged
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@vstinner @aisk
pythongh-85283: Build md5 extension with limited C API (python#110967)
fe1833b
* Replace _Py_strhex() with few lines of code.
* Replace _PyType_GetModuleState() with PyType_GetModuleState().
* Fix make check-c-globals.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@vstinner @Glyphack
pythongh-85283: Build md5 extension with limited C API (python#110967)
fce1c1c
* Replace _Py_strhex() with few lines of code.
* Replace _PyType_GetModuleState() with PyType_GetModuleState().
* Fix make check-c-globals.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@tiran tiran Awaiting requested review from tiran

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@vstinner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.