# Buggy code
def __init__(self, context, framer=None, identity=None, **kwargs):
    """Overloaded initializer for the socket server

    If the identify structure is not passed in, the ModbusControlBlock
    uses its own empty structure.

    :param context: The ModbusServerContext datastore
    :param framer: The framer strategy to use
    :param identity: An optional identify structure
    :param port: The serial port to attach to
    :param stopbits: The number of stop bits to use
    :param bytesize: The bytesize of the serial messages
    :param parity: Which kind of parity to use
    :param baudrate: The baud rate to use for the serial device
    :param timeout: The timeout to use for the serial device
    :param ignore_missing_slaves: True to not send errors on a request
                                    to a missing slave
    """
    self.threads = []
    self.decoder = ServerDecoder()
    self.framer = framer or ModbusAsciiFramer
    self.context = context or ModbusServerContext()
    self.control = ModbusControlBlock()

    if isinstance(identity, ModbusDeviceIdentification):
        self.control.Identity.update(identity)

    self.device = kwargs.get("port", 0)
    self.stopbits = kwargs.get("stopbits", Defaults.Stopbits)
    self.bytesize = kwargs.get("bytesize", Defaults.Bytesize)
    self.parity = kwargs.get("parity", Defaults.Parity)
    self.baudrate = kwargs.get("baudrate", Defaults.Baudrate)
    self.timeout = kwargs.get("timeout", Defaults.Timeout)
    self.ignore_missing_slaves = kwargs.get(
        "ignore_missing_slaves", Defaults.IgnoreMissingSlaves
    )
    self.socket = None
    if self._connect():
        self.is_running = True
        self._build_handler()


# Traceback (AttributeError)
client = ModbusSerialClient(port='notexist', method='rtu')
client.connect()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "lib/python3.6/site-packages/pymodbus/client/sync.py", line 476, in connect
self.socket.interCharTimeout = self.inter_char_timeout
AttributeError: 'NoneType' object has no attribute 'interCharTimeout'

# Fixed code
def __init__(self, context, framer=None, identity=None, **kwargs):
    """Overloaded initializer for the socket server

    If the identify structure is not passed in, the ModbusControlBlock
    uses its own empty structure.

    :param context: The ModbusServerContext datastore
    :param framer: The framer strategy to use
    :param identity: An optional identify structure
    :param port: The serial port to attach to
    :param stopbits: The number of stop bits to use
    :param bytesize: The bytesize of the serial messages
    :param parity: Which kind of parity to use
    :param baudrate: The baud rate to use for the serial device
    :param timeout: The timeout to use for the serial device
    :param ignore_missing_slaves: True to not send errors on a request
                        to a missing slave
    :param broadcast_enable: True to treat unit_id 0 as broadcast address,
                        False to treat 0 as any other unit_id
    """
    self.threads = []
    self.decoder = ServerDecoder()
    self.framer = framer or ModbusAsciiFramer
    self.context = context or ModbusServerContext()
    self.control = ModbusControlBlock()

    if isinstance(identity, ModbusDeviceIdentification):
        self.control.Identity.update(identity)

    self.device = kwargs.get("port", 0)
    self.stopbits = kwargs.get("stopbits", Defaults.Stopbits)
    self.bytesize = kwargs.get("bytesize", Defaults.Bytesize)
    self.parity = kwargs.get("parity", Defaults.Parity)
    self.baudrate = kwargs.get("baudrate", Defaults.Baudrate)
    self.timeout = kwargs.get("timeout", Defaults.Timeout)
    self.ignore_missing_slaves = kwargs.get(
        "ignore_missing_slaves", Defaults.IgnoreMissingSlaves
    )
    self.broadcast_enable = kwargs.get("broadcast_enable", Defaults.broadcast_enable)
    self.socket = None
    if self._connect():
        self.is_running = True
        self._build_handler()