D7815: sha1dc: initial implementation of Python extension

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Mon Jan 13 16:55:51 EST 2020


durin42 added a comment.
durin42 marked 3 inline comments as done.


  Good call on tests, I had the return type of `hexdigest()` wrong. Please do let me know if you think of any missing cases here.

INLINE COMMENTS

> indygreg wrote in cext.c:68
> I'm not super keen on overloading `OverflowError` here. Or is this how `hashlib` works in the Python standard library?

This is new functionality compared to hashlib (this is the "zomg someone is breaking ur sha1" error case), so there's not anything comparable. I didn't really want to go to the effort of defining our own custom exception type for a case we should never see in the wild.

> indygreg wrote in cext.c:107
> Should this be a `memcpy` or some such? Or is this opaque type safe to copy by value? Test coverage for this demonstrating that a seeded hasher which is copied can properly diverge would be appreciated.

I verified by inspection (when writing this) that copying by value is okay here (no pointers, etc), and we now have test coverage that will catch any regression here.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7815/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7815

To: durin42, #hg-reviewers
Cc: indygreg, spectral, mjpieters, mercurial-devel


More information about the Mercurial-devel mailing list