FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-85283: Build md5 extension with limited C API by vstinner · Pull Request #110967 · python/cpython · GitHub

/ cpython Public

gh-85283: Build md5 extension with limited C API - #110967

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:limited_md5
Oct 17, 2023
Merged

gh-85283: Build md5 extension with limited C API#110967
vstinner merged 1 commit into
python:mainfrom
vstinner:limited_md5

Conversation

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

Copy link
Copy Markdown
Member
  • Replace _Py_strhex() with few lines of code.
  • Replace _PyType_GetModuleState() with PyType_GetModuleState().

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

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.

* Replace _Py_strhex() with few lines of code.
* Replace _PyType_GetModuleState() with PyType_GetModuleState().
* Fix make check-c-globals
vstinner enabled auto-merge (squash) October 17, 2023 10:30

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.

vstinner merged commit 4dba0a6 into python:main Oct 17, 2023
vstinner deleted the limited_md5 branch October 17, 2023 10:57
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
* 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
* Replace _Py_strhex() with few lines of code.
* Replace _PyType_GetModuleState() with PyType_GetModuleState().
* Fix make check-c-globals.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL