# Buggy code
def _process_class(
    _cls, init, repr, eq, order, unsafe_hash, frozen, validate_assignment
):
    post_init_original = getattr(_cls, "__post_init__", None)
    _cls.__post_init__ = post_init
    cls = dataclasses._process_class(_cls, init, repr, eq, order, unsafe_hash, frozen)

    fields = {
        name: (field.type, field.default)
        for name, field in cls.__dataclass_fields__.items()
    }
    cls.__post_init_original__ = post_init_original
    cls.__pydantic_model__ = create_model(cls.__name__, **fields)
    cls.__initialised__ = False

    if validate_assignment and not frozen:
        cls.__setattr__ = setattr_validate_assignment
    return cls


# Traceback (RecursionError)
Traceback (most recent call last):
File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-9-10a7116ca691>", line 12, in <module>
B(a='a', b='b')
File "<string>", line 4, in __init__
File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/dataclasses.py", line 13, in post_init
self.__post_init_original__()
File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/dataclasses.py", line 13, in post_init
self.__post_init_original__()
File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/dataclasses.py", line 13, in post_init
self.__post_init_original__()
[Previous line repeated 952 more times]
File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/dataclasses.py", line 9, in post_init
d = validate_model(self.__pydantic_model__, self.__dict__)
File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/main.py", line 484, in validate_model
v_, errors_ = field.validate(value, values, loc=field.alias, cls=model.__class__)
File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/fields.py", line 303, in validate
v, errors = self._validate_singleton(v, values, loc, cls)
File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/fields.py", line 406, in _validate_singleton
return self._apply_validators(v, values, loc, cls, self.validators)
File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/fields.py", line 412, in _apply_validators
v = validator(v)
File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/validators.py", line 23, in str_validator
if isinstance(v, (str, NoneType)):
RecursionError: maximum recursion depth exceeded in __instancecheck__

# Fixed code
def _process_class(
    _cls, init, repr, eq, order, unsafe_hash, frozen, validate_assignment
):
    post_init_original = getattr(_cls, "__post_init__", None)
    if post_init_original and post_init_original.__name__ == "_pydantic_post_init":
        post_init_original = None
    _cls.__post_init__ = _pydantic_post_init
    cls = dataclasses._process_class(_cls, init, repr, eq, order, unsafe_hash, frozen)

    fields = {
        name: (field.type, field.default)
        for name, field in cls.__dataclass_fields__.items()
    }
    cls.__post_init_original__ = post_init_original
    cls.__pydantic_model__ = create_model(cls.__name__, **fields)
    cls.__initialised__ = False

    if validate_assignment and not frozen:
        cls.__setattr__ = setattr_validate_assignment
    return cls