Modified exception handling for python3

* Python3's SyntaxError exception is different from python2's,
  so changed to obtain value by field names