diff --git a/parsons/etl/etl.py b/parsons/etl/etl.py index a1e9e99570..2bc15081ca 100644 --- a/parsons/etl/etl.py +++ b/parsons/etl/etl.py @@ -1,4 +1,5 @@ import logging +import sys import petl @@ -658,11 +659,20 @@ def unpack_nested_columns_as_rows(self, column, key="id", expand_original=False) orig.concat(melted_list) # Add unique id column by hashing all the other fields if "uid" not in self.columns: - orig.add_column( - "uid", - lambda row: hashlib.md5(str.encode("".join([str(x) for x in row])), - usedforsecurity=False).hexdigest(), - ) + if sys.version_info.minor >= 9: + orig.add_column( + "uid", + lambda row: hashlib.md5( + str.encode("".join([str(x) for x in row])), usedforsecurity=False + ).hexdigest(), + ) + elif sys.version_info.minor < 9: + orig.add_column( + "uid", + lambda row: hashlib.md5( + str.encode("".join([str(x) for x in row])) + ).hexdigest(), + ) orig.move_column("uid", 0) # Rename value column in case this is done again to this Table @@ -674,11 +684,18 @@ def unpack_nested_columns_as_rows(self, column, key="id", expand_original=False) else: orig = self.remove_column(column) # Add unique id column by hashing all the other fields - melted_list.add_column( - "uid", - lambda row: hashlib.md5(str.encode("".join([str(x) for x in row])), - usedforsecurity=False).hexdigest(), - ) + if sys.version_info.minor >= 9: + melted_list.add_column( + "uid", + lambda row: hashlib.md5( + str.encode("".join([str(x) for x in row])), usedforsecurity=False + ).hexdigest(), + ) + elif sys.version_info.minor < 9: + melted_list.add_column( + "uid", + lambda row: hashlib.md5(str.encode("".join([str(x) for x in row]))).hexdigest(), + ) melted_list.move_column("uid", 0) output = melted_list