# Buggy code
def _build_fstring(self, pos, ustring, format_args):
    # Issues formatting warnings instead of errors since we really only catch a few errors by accident.
    args = iter(format_args)
    substrings = []
    can_be_optimised = True
    for s in re.split(self._parse_string_format_regex, ustring):
        if not s:
            continue
        if s == "%%":
            substrings.append(
                ExprNodes.UnicodeNode(
                    pos, value=EncodedString("%"), constant_result="%"
                )
            )
            continue
        if s[0] != "%":
            if s[-1] == "%":
                warning(pos, "Incomplete format: '...%s'" % s[-3:], level=1)
                can_be_optimised = False
            substrings.append(
                ExprNodes.UnicodeNode(pos, value=EncodedString(s), constant_result=s)
            )
            continue
        format_type = s[-1]
        try:
            arg = next(args)
        except StopIteration:
            warning(pos, "Too few arguments for format placeholders", level=1)
            can_be_optimised = False
            break
        if arg.is_starred:
            can_be_optimised = False
            break
        if format_type in "asrfdoxX":
            format_spec = s[1:]
            if format_type in "doxX" and "." in format_spec:
                # Precision is not allowed for integers in format(), but ok in %-formatting.
                can_be_optimised = False
            elif format_type in "ars":
                format_spec = format_spec[:-1]
            substrings.append(
                ExprNodes.FormattedValueNode(
                    arg.pos,
                    value=arg,
                    conversion_char=format_type if format_type in "ars" else None,
                    format_spec=ExprNodes.UnicodeNode(
                        pos,
                        value=EncodedString(format_spec),
                        constant_result=format_spec,
                    )
                    if format_spec
                    else None,
                )
            )
        else:
            # keep it simple for now ...
            can_be_optimised = False
            break

    if not can_be_optimised:
        # Print all warnings we can find before finally giving up here.
        return None

    try:
        next(args)
    except StopIteration:
        pass
    else:
        warning(pos, "Too many arguments for format placeholders", level=1)
        return None

    node = ExprNodes.JoinedStrNode(pos, values=substrings)
    return self.visit_JoinedStrNode(node)


# Traceback (ValueError)
(<class 'float'>, <class 'float'>)
(50.0, 50.0)
string being formatted=50
(<class 'float'>, <class 'float'>)
(50.0, 50.0)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "cytest/test.py", line 16, in init cytest.test
test_func_with_tuple(50.,50.)
File "cytest/test.py", line 11, in cytest.test.test_func_with_tuple
s = 'string being formatted=%d-%d' % (a,b)
ValueError: Unknown format code 'd' for object of type 'float'

# Fixed code
def _build_fstring(self, pos, ustring, format_args):
    # Issues formatting warnings instead of errors since we really only catch a few errors by accident.
    args = iter(format_args)
    substrings = []
    can_be_optimised = True
    for s in re.split(self._parse_string_format_regex, ustring):
        if not s:
            continue
        if s == "%%":
            substrings.append(
                ExprNodes.UnicodeNode(
                    pos, value=EncodedString("%"), constant_result="%"
                )
            )
            continue
        if s[0] != "%":
            if s[-1] == "%":
                warning(pos, "Incomplete format: '...%s'" % s[-3:], level=1)
                can_be_optimised = False
            substrings.append(
                ExprNodes.UnicodeNode(pos, value=EncodedString(s), constant_result=s)
            )
            continue
        format_type = s[-1]
        try:
            arg = next(args)
        except StopIteration:
            warning(pos, "Too few arguments for format placeholders", level=1)
            can_be_optimised = False
            break
        if arg.is_starred:
            can_be_optimised = False
            break
        if format_type in "asrfdoxX":
            format_spec = s[1:]
            conversion_char = None
            if format_type in "doxX" and "." in format_spec:
                # Precision is not allowed for integers in format(), but ok in %-formatting.
                can_be_optimised = False
            elif format_type in "ars":
                format_spec = format_spec[:-1]
                conversion_char = format_type
            elif format_type == "d":
                # '%d' formatting supports float, but '{obj:d}' does not => convert to int first.
                conversion_char = "d"
            substrings.append(
                ExprNodes.FormattedValueNode(
                    arg.pos,
                    value=arg,
                    conversion_char=conversion_char,
                    format_spec=ExprNodes.UnicodeNode(
                        pos,
                        value=EncodedString(format_spec),
                        constant_result=format_spec,
                    )
                    if format_spec
                    else None,
                )
            )
        else:
            # keep it simple for now ...
            can_be_optimised = False
            break

    if not can_be_optimised:
        # Print all warnings we can find before finally giving up here.
        return None

    try:
        next(args)
    except StopIteration:
        pass
    else:
        warning(pos, "Too many arguments for format placeholders", level=1)
        return None

    node = ExprNodes.JoinedStrNode(pos, values=substrings)
    return self.visit_JoinedStrNode(node)