How to use the vine.five.exec_ function in vine

To help you get started, we’ve selected a few vine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github celery / celery / celery / utils / serialization.py View on Github external
elif isinstance(obj, datetime.timedelta):
        return str(obj)
    else:
        if unknown_type_filter is None:
            raise ValueError(
                'Unsupported type: {0!r} {1!r} (parent: {2})'.format(
                    type(obj), obj, key))
        return unknown_type_filter(obj)


# Since PyPy 3 targets Python 3.2, 'raise exc from None' will
# raise a TypeError so we need to look for Python 3.3 or newer
if PY33:  # pragma: no cover
    from vine.five import exec_
    _raise_with_context = None  # for flake8
    exec_("""def _raise_with_context(exc, ctx): raise exc from ctx""")

    def raise_with_context(exc):
        exc_info = sys.exc_info()
        if not exc_info:
            raise exc
        elif exc_info[1] is exc:
            raise
        _raise_with_context(exc, exc_info[1])
else:
    def raise_with_context(exc):
        exc_info = sys.exc_info()
        if not exc_info:
            raise exc
        if exc_info[1] is exc:
            raise
        elif exc_info[2]: