python: use errors more specific than RuntimeError

KeyError is documented as:
"Raised when a mapping (dictionary) key is not found in the set of
existing keys."

TypeError is documented as:
"Raised when an operation or function is applied to an object of
inappropriate type."

RuntimeError is documented as:
"Raised when an error is detected that doesn’t fall in any of the other
categories."

Let's be more specific with exceptions. The exception all inherit from
StandardError (and from Exception), but not from RuntimeError, so this
might need some code changes (if users would catch this specific error).
However, this behavior was not documented so it is perfectly fine to
change it.
python: use PyErr_NoMemory

If malloc fails, just throw a NoMemory exception rather than showing
"RuntimeError: Cannot allocate memory".
python: check some types for get_value

Recognise early that a value passed to node_get_value is not a dict
rather than spitting out "no 'key' element in dictionary".

Detect errors for invalid `t` elements instead of silently using `-1`.
python: fix crash by validating key and value

User-visible changes: no crashes if you try to pass a non-str type as
key/value in Python 3. Exceptions are thrown rather than silently
ignoring type violations (such as passing a Unicode string as value
in Python 2).

Until now, Python 2 keys and values were assumes to be bytes, in
Python 3 these were seen as Unicode strings instead. Remove the
compile-check for a deprecated Python 2 function (`PyString_AsString`)
and check for byte types instead.

For keys, accept both strings and bytes as the common case is to pass
a ASCII string name. (The `\u20ac` Unicode character (Euro-sign) is
apparently also valid as key name, verified with Python 3 and
Windows 7).

For values, be more conservative and reject all types except bytes. This
better matches the C API and removes the burden of character conversion
from the wrapper. Instead, callers should know the correct encoding
and terminate strings.

Modify tests to specify bytes instead of strings. (Otherwise Python 3
would break while Python 2 still passes.)
python: add heavier tests for setvalue

Ensure that invalid types are not silently ignored (and test to avoid
segfaults).
generator: Fix mixed tabs/spaces

vim :set ts=8 :retab