# Buggy code
def _dense_fit(self, X, y, sample_weight, solver_type, kernel, random_seed):
    if callable(self.kernel):
        # you must store a reference to X to compute the kernel in predict
        # TODO: add keyword copy to copy on demand
        self.__Xfit = X
        X = self._compute_kernel(X)

        if X.shape[0] != X.shape[1]:
            raise ValueError("X.shape[0] should be equal to X.shape[1]")

    libsvm.set_verbosity_wrap(self.verbose)

    if six.PY2:
        # In python2 ensure kernel is ascii bytes to prevent a TypeError
        if isinstance(kernel, six.types.UnicodeType):
            kernel = str(kernel)
    if six.PY3:
        # In python3 ensure kernel is utf8 unicode to prevent a TypeError
        if isinstance(kernel, bytes):
            kernel = str(kernel, "utf8")

    # we don't pass **self.get_params() to allow subclasses to
    # add other parameters to __init__
    (
        self.support_,
        self.support_vectors_,
        self.n_support_,
        self.dual_coef_,
        self.intercept_,
        self.probA_,
        self.probB_,
        self.fit_status_,
    ) = libsvm.fit(
        X,
        y,
        svm_type=solver_type,
        sample_weight=sample_weight,
        class_weight=self.class_weight_,
        kernel=kernel,
        C=self.C,
        nu=self.nu,
        probability=self.probability,
        degree=self.degree,
        shrinking=self.shrinking,
        tol=self.tol,
        cache_size=self.cache_size,
        coef0=self.coef0,
        gamma=self._gamma,
        epsilon=self.epsilon,
        max_iter=self.max_iter,
        random_seed=random_seed,
    )

    self._warn_from_fit_status()


# Traceback (TypeError)
Traceback (most recent call last):
File "error.py", line 8, in <module>
svm.predict_proba(X)
File "/home/bcyphers/scratch/venv/local/lib/python2.7/site-packages/sklearn/svm/base.py", line 600, ina
return pred_proba(X)
File "/home/bcyphers/scratch/venv/local/lib/python2.7/site-packages/sklearn/svm/base.py", line 648, ina
cache_size=self.cache_size, coef0=self.coef0, gamma=self._gamma)
TypeError: Argument 'kernel' has incorrect type (expected str, got newstr)

# Fixed code
def _dense_fit(self, X, y, sample_weight, solver_type, kernel, random_seed):
    if callable(self.kernel):
        # you must store a reference to X to compute the kernel in predict
        # TODO: add keyword copy to copy on demand
        self.__Xfit = X
        X = self._compute_kernel(X)

        if X.shape[0] != X.shape[1]:
            raise ValueError("X.shape[0] should be equal to X.shape[1]")

    libsvm.set_verbosity_wrap(self.verbose)

    # we don't pass **self.get_params() to allow subclasses to
    # add other parameters to __init__
    (
        self.support_,
        self.support_vectors_,
        self.n_support_,
        self.dual_coef_,
        self.intercept_,
        self.probA_,
        self.probB_,
        self.fit_status_,
    ) = libsvm.fit(
        X,
        y,
        svm_type=solver_type,
        sample_weight=sample_weight,
        class_weight=self.class_weight_,
        kernel=kernel,
        C=self.C,
        nu=self.nu,
        probability=self.probability,
        degree=self.degree,
        shrinking=self.shrinking,
        tol=self.tol,
        cache_size=self.cache_size,
        coef0=self.coef0,
        gamma=self._gamma,
        epsilon=self.epsilon,
        max_iter=self.max_iter,
        random_seed=random_seed,
    )

    self._warn_from_fit_status()