Brine is a simple, fast and secure object serializer for immutable objects.

The following types are supported: int, bool, str, float, unicode, bytes, slice, complex, tuple (of simple types), frozenset (of simple types) as well as the following singletons: None, NotImplemented, and Ellipsis.

>>> x = ("he", 7, u"llo", 8, (), 900, None, True, Ellipsis, 18.2, 18.2j + 13,
... slice(1,2,3), frozenset([5,6,7]), NotImplemented)
>>> dumpable(x)
>>> y = dump(x)
>>> y.encode("hex")
>>> z = load(y)
>>> x == z

Converts (dumps) the given object to a byte-string representation


obj – any dumpable() object


a byte-string representation of the object


Recreates (loads) an object from its byte-string representation


data – the byte-string representation of an object


the dumped object


Indicates whether the given object is dumpable by brine


True if the object is dumpable (e.g., dump() would succeed), False otherwise


Vinegar (“when things go sour”) is a safe serializer for exceptions. The configuration parameters control its mode of operation, for instance, whether to allow old-style exceptions (that do not derive from Exception), whether to allow the load() to import custom modules (imposes a security risk), etc.

Note that by changing the configuration parameters, this module can be made non-secure. Keep this in mind.

rpyc.core.vinegar.dump(typ, val, tb, include_local_traceback, include_local_version)[source]

Dumps the given exceptions info, as returned by sys.exc_info()

  • typ – the exception’s type (class)

  • val – the exceptions’ value (instance)

  • tb – the exception’s traceback (a traceback object)

  • include_local_traceback – whether or not to include the local traceback in the dumped info. This may expose the other side to implementation details (code) and package structure, and may theoretically impose a security risk.


A tuple of ((module name, exception name), arguments, attributes, traceback text). This tuple can be safely passed to brine.dump

rpyc.core.vinegar.load(val, import_custom_exceptions, instantiate_custom_exceptions, instantiate_oldstyle_exceptions)[source]

Loads a dumped exception (the tuple returned by dump()) info a throwable exception object. If the exception cannot be instantiated for any reason (i.e., the security parameters do not allow it, or the exception class simply doesn’t exist on the local machine), a GenericException instance will be returned instead, containing all of the original exception’s details.

  • val – the dumped exception

  • import_custom_exceptions – whether to allow this function to import custom modules (imposes a security risk)

  • instantiate_custom_exceptions – whether to allow this function to instantiate “custom exceptions” (i.e., not one of the built-in exceptions, such as ValueError, OSError, etc.)

  • instantiate_oldstyle_exceptions – whether to allow this function to instantiate exception classes that do not derive from BaseException. This is required to support old-style exceptions. Not applicable for Python 3 and above.


A throwable exception object

exception rpyc.core.vinegar.GenericException[source]

A ‘generic exception’ that is raised when the exception the gotten from the other party cannot be instantiated locally