Handle AttributeError also when importing segment function

This commit is contained in:
ZyX 2013-03-11 18:24:15 +04:00
parent 1ef1ad7cfe
commit fe6f1bf4d5
2 changed files with 7 additions and 3 deletions

View File

@ -598,9 +598,14 @@ def check_segment_name(name, data, context, echoerr):
func = getattr(__import__(unicode(module), fromlist=[unicode(name)]), unicode(name))
except ImportError:
echoerr(context='Error while checking segments (key {key})'.format(key=context_key(context)),
problem='failed to import function {0} from module {1}'.format(name, module),
problem='failed to import module {0}'.format(module),
problem_mark=module.mark)
return True, False, True
except AttributeError:
echoerr(context='Error while loading segment function (key {key})'.format(key=context_key(context)),
problem='failed to load function {0} from module {1}'.format(name, module),
problem_mark=match_name.mark)
return True, False, True
if not callable(func):
echoerr(context='Error while checking segments (key {key})'.format(key=context_key(context)),

View File

@ -8,10 +8,9 @@ from .error import MarkedError, Mark, NON_PRINTABLE
import codecs
try:
from __builtin__ import unicode, unichr
from __builtin__ import unicode
except ImportError:
unicode = str # NOQA
unichr = chr # NOQA
class ReaderError(MarkedError):