| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
|
||
| >>> import io, hashlib, hmac | ||
| >>> with open(hashlib.__file__, "rb") as f: | ||
| >>> with open("path/to/file", "rb") as f: |
There was a problem hiding this comment.
the previous code worked because it passes doctest. It probably runs from the repo root, what happens if you use "Doc/library/hashlib.rst" here?
Sorry, something went wrong.
There was a problem hiding this comment.
Oh, now its even cleverer in that this was hand-picked because we know its gonna pass doctest? 🤦
Sorry, something went wrong.
There was a problem hiding this comment.
| >>> with open("path/to/file", "rb") as f: | |
| >>> with open("Doc/library/hashlib.rst", "rb") as f: |
Sorry, something went wrong.
There was a problem hiding this comment.
FileNotFoundError: [Errno 2] No such file or directory: 'Doc/library/hashlib.rst'
https://github.com/python/cpython/actions/runs/15196498586/job/42741793385?pr=134540#step:8:405
Sorry, something went wrong.
|
Thanks @thejcannon for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
Sorry, something went wrong.
|
GH-134549 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
|
GH-134550 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
I love the cleverness and quirkiness of the hashlib documentation choosing to hash the hashlib module itself, however it is exactly that: "clever" and "quirky". Unfortunately, I've seen Python newbies and intermediates struggling to understand this example when trying to hash files themselves (not the least because the example does hashlib.__file__ and not __file__ or some_other_module.__file__).
So, let's move to something more "obvious" 👍 at the cost of being a slightly less silly place 👎
Open question to the room on whether this should be backported.
📚 Documentation preview 📚: https://cpython-previews--134540.org.readthedocs.build/