From fc6f743c52d5769e665826128687ddbad9d4a5d7 Mon Sep 17 00:00:00 2001 From: Mark Hatle Date: Thu, 6 Oct 2022 16:53:22 -0500 Subject: bitbake: utils/ply: Update md5 to better report errors with hashlib In the case where hashlib is not available, the try would fail and fall through resulting in a backtrace on the usage of the 'sig'. The backtrace itself was confusing and made it difficult to determine what went wrong. Update the import to be in it's own try block with an appropriate message to indicate what went wrong. Note, the current version of ply all of this code has been restructured so this is not applicable upstream. Additionally, some versions of hashlib don't appear to implement the second FIPS related argument. Detect this and support both versions. (Bitbake rev: 484ab42f440070c0369b81f5c69da860fa47a798) Signed-off-by: Mark Hatle Signed-off-by: Mark Hatle Signed-off-by: Luca Ceresoli Signed-off-by: Richard Purdie --- bitbake/lib/ply/yacc.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'bitbake/lib/ply') diff --git a/bitbake/lib/ply/yacc.py b/bitbake/lib/ply/yacc.py index 767c4e4674..381b50cf0b 100644 --- a/bitbake/lib/ply/yacc.py +++ b/bitbake/lib/ply/yacc.py @@ -2798,7 +2798,14 @@ class ParserReflect(object): def signature(self): try: import hashlib + except ImportError: + raise RuntimeError("Unable to import hashlib") + try: sig = hashlib.new('MD5', usedforsecurity=False) + except TypeError: + # Some configurations don't appear to support two arguments + sig = hashlib.new('MD5') + try: if self.start: sig.update(self.start.encode('latin-1')) if self.prec: -- cgit v1.2.3-54-g00ecf