Fixed conversion of boolean to Python type

bool() converts any non-empty string to True,
so we need to explicitly check the string content.

Backporting the patch to earlier versions should be considered.