# Buggy code
def update_serial(self, new_serial):
    """Updates the serial number of a device.

    The "serial number" used with adb's `-s` arg is not necessarily the
    actual serial number. For remote devices, it could be a combination of
    host names and port numbers.

    This is used for when such identifier of remote devices changes during
    a test. For example, when a remote device reboots, it may come back
    with a different serial number.

    This is NOT meant for switching the object to represent another device.

    We intentionally did not make it a regular setter of the serial
    property so people don't accidentally call this without understanding
    the consequences.

    Args:
        new_serial: string, the new serial number for the same device.

    Raises:
        DeviceError: tries to update serial when any service is running.
    """
    if self.has_active_service:
        raise DeviceError(
            self, "Cannot change device serial number when there is service running."
        )
    if self._debug_tag == self.serial:
        self._debug_tag = new_serial
    self._serial = new_serial
    self.adb.serial = new_serial
    self.fastboot.serial = new_serial


# Traceback (TypeError)
Traceback (most recent call last):
File ".../mobly/test_runner.py", line 420, in _register_controller
objects = create(controller_config)
File ".../mobly/controllers/android_device.py", line 87, in create
ads = get_instances_with_configs(configs)
File ".../mobly/controllers/android_device.py", line 257, in get_instances_with_configs
ad = AndroidDevice(serial)
File ".../mobly/controllers/android_device.py", line 402, in __init__
if not self.is_bootloader and self.is_rootable:
File ".../mobly/controllers/android_device.py", line 637, in is_rootable
build_type_output = self.adb.getprop('ro.build.type').lower()
File ".../mobly/controllers/android_device_lib/adb.py", line 175, in getprop
return self.shell('getprop %s' % prop_name).decode('utf-8').strip()
File ".../mobly/controllers/android_device_lib/adb.py", line 199, in adb_call
clean_name, args, shell=shell, timeout=timeout)
File ".../mobly/controllers/android_device_lib/adb.py", line 161, in _exec_adb_cmd
return self._exec_cmd(adb_cmd, shell=shell, timeout=timeout)
File ".../mobly/controllers/android_device_lib/adb.py", line 122, in _exec_cmd
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=shell)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
TypeError: execv() arg 2 must contain only strings

# Fixed code
def update_serial(self, new_serial):
    """Updates the serial number of a device.

    The "serial number" used with adb's `-s` arg is not necessarily the
    actual serial number. For remote devices, it could be a combination of
    host names and port numbers.

    This is used for when such identifier of remote devices changes during
    a test. For example, when a remote device reboots, it may come back
    with a different serial number.

    This is NOT meant for switching the object to represent another device.

    We intentionally did not make it a regular setter of the serial
    property so people don't accidentally call this without understanding
    the consequences.

    Args:
        new_serial: string, the new serial number for the same device.

    Raises:
        DeviceError: tries to update serial when any service is running.
    """
    new_serial = str(new_serial)
    if self.has_active_service:
        raise DeviceError(
            self, "Cannot change device serial number when there is service running."
        )
    if self._debug_tag == self.serial:
        self._debug_tag = new_serial
    self._serial = new_serial
    self.adb.serial = new_serial
    self.fastboot.serial = new_serial