# Buggy code
def __setitem__(self, key, value):
    key = com.apply_if_callable(key, self)

    # see if we can slice the rows
    indexer = convert_to_index_sliceable(self, key)
    if indexer is not None:
        # either we have a slice or we have a string that can be converted
        #  to a slice for partial-string date indexing
        return self._setitem_slice(indexer, value)

    if isinstance(key, DataFrame) or getattr(key, "ndim", None) == 2:
        self._setitem_frame(key, value)
    elif isinstance(key, (Series, np.ndarray, list, Index)):
        self._setitem_array(key, value)
    elif isinstance(value, DataFrame):
        self._set_item_frame_value(key, value)
    else:
        # set column
        self._set_item(key, value)


# Traceback (ValueError)
In [2]: df = pd.DataFrame(index=range(3), columns=['A', 'B', 'C', 'D', 'E', 'F'])

In [3]: df.loc[0, ['A', 'D']] = (1,2)

In [4]: df.loc[:, ['B', 'E']] = (1,2)

In [5]: df[['C', 'F']] = (1,2)

In [6]: df
Out[6]:
A  B  C    D  E  F
0    1  1  1    2  2  2
1  NaN  1  1  NaN  2  2
2  NaN  1  1  NaN  2  2

In [7]: dfdup = pd.DataFrame(index=range(3), columns=['A', 'B', 'C']*2)

In [8]: dfdup.loc[0, 'A'] = (1,2) # Works

In [9]: dfdup.loc[:, 'B'] = (1,2) # Works

In [10]: dfdup['C'] = (1,2) # Fails
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-10-17d5611af828> in <module>()
----> 1 dfdup['C'] = (1,2)

/home/pietro/nobackup/repo/pandas/pandas/core/frame.py in __setitem__(self, key, value)
2421         else:
2422             # set column
-> 2423             self._set_item(key, value)
2424
2425     def _setitem_slice(self, key, value):

/home/pietro/nobackup/repo/pandas/pandas/core/frame.py in _set_item(self, key, value)
2487
2488         self._ensure_valid_index(value)
-> 2489         value = self._sanitize_column(key, value)
2490         NDFrame._set_item(self, key, value)
2491

/home/pietro/nobackup/repo/pandas/pandas/core/frame.py in _sanitize_column(self, key, value, broadcast)
2658
2659             # turn me into an ndarray
-> 2660             value = _sanitize_index(value, self.index, copy=False)
2661             if not isinstance(value, (np.ndarray, Index)):
2662                 if isinstance(value, list) and len(value) > 0:

/home/pietro/nobackup/repo/pandas/pandas/core/series.py in _sanitize_index(data, index, copy)
2847
2848     if len(data) != len(index):
-> 2849         raise ValueError('Length of values does not match length of ' 'index')
2850
2851     if isinstance(data, PeriodIndex):

ValueError: Length of values does not match length of index

In [11]: dfdup
Out[11]:
A  B    C    A  B    C
0    1  1  NaN    2  2  NaN
1  NaN  1  NaN  NaN  2  NaN
2  NaN  1  NaN  NaN  2  NaN

# Fixed code
def __setitem__(self, key, value):
    key = com.apply_if_callable(key, self)

    # see if we can slice the rows
    indexer = convert_to_index_sliceable(self, key)
    if indexer is not None:
        # either we have a slice or we have a string that can be converted
        #  to a slice for partial-string date indexing
        return self._setitem_slice(indexer, value)

    if isinstance(key, DataFrame) or getattr(key, "ndim", None) == 2:
        self._setitem_frame(key, value)
    elif isinstance(key, (Series, np.ndarray, list, Index)):
        self._setitem_array(key, value)
    elif isinstance(value, DataFrame):
        self._set_item_frame_value(key, value)
    elif is_list_like(value) and 1 < len(self.columns.get_indexer_for([key])) == len(
        value
    ):
        # Column to set is duplicated
        self._setitem_array([key], value)
    else:
        # set column
        self._set_item(key, value)