From df233d51c419be0cf63af6f6ba55335ab43ca1d0 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Wed, 10 Aug 2022 23:38:35 +0200 Subject: [PATCH 1/3] BUG: use usedforsecurity for md5 in cross merge --- pandas/core/reshape/merge.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index 77a0d34132da0..e1ea4dbf03e31 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -10,6 +10,7 @@ import string from typing import ( TYPE_CHECKING, + Callable, Hashable, cast, ) @@ -30,6 +31,7 @@ Suffixes, npt, ) +from pandas.compat import PY39 from pandas.errors import MergeError from pandas.util._decorators import ( Appender, @@ -1311,7 +1313,16 @@ def _create_cross_configuration( DataFrames with cross_col, the merge operation set to inner and the column to join over. """ - cross_col = f"_cross_{hashlib.md5().hexdigest()}" + _md5: Callable + if PY39: + + def _md5(_hashlib_md5=hashlib.md5): + return _hashlib_md5(usedforsecurity=False) + + else: + _md5 = hashlib.md5 + + cross_col = f"_cross_{_md5().hexdigest()}" how = "inner" return ( left.assign(**{cross_col: 1}), From 7f694ea9d4010dc3935896afea7c2f2df50a0aca Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Wed, 10 Aug 2022 23:40:57 +0200 Subject: [PATCH 2/3] BUG: use usedforsecurity for md5 in cross merge --- doc/source/whatsnew/v1.5.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index a0d33cb513722..d794692de5005 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -1095,6 +1095,7 @@ Reshaping - Bug in :func:`concat` not sorting the column names when ``None`` is included (:issue:`47331`) - Bug in :func:`concat` with identical key leads to error when indexing :class:`MultiIndex` (:issue:`46519`) - Bug in :func:`pivot_table` raising ``TypeError`` when ``dropna=True`` and aggregation column has extension array dtype (:issue:`47477`) +- Bug in :func:`merge` raising error for ``how="cross"`` when using ``FIPS`` mode in ssl library (:issue:`48024`) - Bug in :meth:`DataFrame.join` with a list when using suffixes to join DataFrames with duplicate column names (:issue:`46396`) - Bug in :meth:`DataFrame.pivot_table` with ``sort=False`` results in sorted index (:issue:`17041`) - Bug in :meth:`concat` when ``axis=1`` and ``sort=False`` where the resulting Index was a :class:`Int64Index` instead of a :class:`RangeIndex` (:issue:`46675`) From 2216dda7ab31cf687b5e5c77e0ac2a686b20c886 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Thu, 11 Aug 2022 00:39:02 +0200 Subject: [PATCH 3/3] Use uuid --- pandas/core/reshape/merge.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index e1ea4dbf03e31..4b8547bd6a232 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -6,14 +6,13 @@ import copy import datetime from functools import partial -import hashlib import string from typing import ( TYPE_CHECKING, - Callable, Hashable, cast, ) +import uuid import warnings import numpy as np @@ -31,7 +30,6 @@ Suffixes, npt, ) -from pandas.compat import PY39 from pandas.errors import MergeError from pandas.util._decorators import ( Appender, @@ -1313,16 +1311,7 @@ def _create_cross_configuration( DataFrames with cross_col, the merge operation set to inner and the column to join over. """ - _md5: Callable - if PY39: - - def _md5(_hashlib_md5=hashlib.md5): - return _hashlib_md5(usedforsecurity=False) - - else: - _md5 = hashlib.md5 - - cross_col = f"_cross_{_md5().hexdigest()}" + cross_col = f"_cross_{uuid.uuid4()}" how = "inner" return ( left.assign(**{cross_col: 1}),