Previously, writing code like
@fdb.transactional
def foo(tr):
yield tr.get('a')
yield tr.get('b')
print(foo(db))
was accepted by the python bindings, but had surprising semantics. The
function returned by @fdb.transactional opens a transaction, runs foo(),
commits the transaction, and then returns the generator returned by foo().
This generator then uses the committed transaction. This worked before API
version 410 (FDB 4.1), and hasn't worked since. This will also be a problem if
a closure is returned from foo() that contains `tr`, but it's much harder to
check that in Python.
Rather than allow users to hit an unexpected and mysterious "Operation issued
while a commit was outstanding" exception, it's nicer to explicitly highlight
this problem as soon as we can. Unfortunately, we have no way to know that a
function will return a generator until we call it, so that's the soonest we can
give a more informative error.
Python 2 resolves escape characters when printing byte strings,
which doesn't seem useful in this context.
I replaced __str__ since it defaults to __repr__ and the change
should be suitable for both cases.