# Buggy code
def _onActiveExtruderChanged(self):
    new_active_stack = ExtruderManager.getInstance().getActiveExtruderStack()
    # if not new_active_stack:
    #     new_active_stack = self._global_container_stack

    if new_active_stack != self._active_container_stack:  # Check if changed
        if (
            self._active_container_stack
        ):  # Disconnect signal from old container (if any)
            self._active_container_stack.propertyChanged.disconnect(
                self._onPropertyChanged
            )
            self._active_container_stack.containersChanged.disconnect(
                self._onContainersChanged
            )

        self._active_container_stack = new_active_stack
        self._active_container_stack.propertyChanged.connect(self._onPropertyChanged)
        self._active_container_stack.containersChanged.connect(
            self._onContainersChanged
        )
        self._update()  # Ensure that the settings_with_inheritance_warning list is populated.


# Traceback (ValueError)
Traceback (most recent call last):
File "/usr/bin/cura", line 141, in <module>
app.run()
File "/usr/lib/python3/dist-packages/cura/CuraApplication.py", line 686, in run
self._volume = BuildVolume.BuildVolume(root)
File "/usr/lib/python3/dist-packages/cura/BuildVolume.py", line 107, in __init__
Application.getInstance().getMachineManager().activeQualityChanged.connect(self._onStackChanged)
File "/usr/lib/python3/dist-packages/cura/CuraApplication.py", line 747, in getMachineManager
self._machine_manager = MachineManager.createMachineManager()
File "/usr/lib/python3/dist-packages/cura/Settings/MachineManager.py", line 1328, in createMachineManager
return MachineManager()
File "/usr/lib/python3/dist-packages/cura/Settings/MachineManager.py", line 119, in __init__
self.setActiveMachine(active_machine_id)
File "/usr/lib/python3/dist-packages/cura/Settings/MachineManager.py", line 388, in setActiveMachine
Application.getInstance().setGlobalContainerStack(containers[0])
File "/usr/lib/python3/dist-packages/UM/Application.py", line 160, in setGlobalContainerStack
self.globalContainerStackChanged.emit()
File "/usr/lib/python3/dist-packages/UM/Signal.py", line 212, in emit
self.__performEmit(*args, **kwargs)
File "/usr/lib/python3/dist-packages/UM/Signal.py", line 315, in __performEmit
func(dest, *args, **kwargs)
File "/usr/lib/python3/dist-packages/cura/BuildVolume.py", line 500, in _onStackChanged
self._updateDisallowedAreas()
File "/usr/lib/python3/dist-packages/cura/BuildVolume.py", line 607, in _updateDisallowedAreas
disallowed_border_size = self._getEdgeDisallowedSize()
File "/usr/lib/python3/dist-packages/cura/BuildVolume.py", line 966, in _getEdgeDisallowedSize
move_from_wall_radius = max(move_from_wall_radius, max(self._getSettingFromAllExtruders("infill_wipe_dist")))
ValueError: max() arg is an empty sequence

# Fixed code
def _onActiveExtruderChanged(self):
    new_active_stack = ExtruderManager.getInstance().getActiveExtruderStack()
    if not new_active_stack:
        self._active_container_stack = None
        return

    if new_active_stack != self._active_container_stack:  # Check if changed
        if (
            self._active_container_stack
        ):  # Disconnect signal from old container (if any)
            self._active_container_stack.propertyChanged.disconnect(
                self._onPropertyChanged
            )
            self._active_container_stack.containersChanged.disconnect(
                self._onContainersChanged
            )

        self._active_container_stack = new_active_stack
        self._active_container_stack.propertyChanged.connect(self._onPropertyChanged)
        self._active_container_stack.containersChanged.connect(
            self._onContainersChanged
        )
        self._update()  # Ensure that the settings_with_inheritance_warning list is populated.