[Piglit] [PATCH] framework: Never redirect sys.stderr to /dev/null.

Jose Fonseca jfonseca at vmware.com
Tue Dec 8 08:28:45 PST 2015


On 07/12/15 18:20, Dylan Baker wrote:
> On Mon, Dec 07, 2015 at 03:31:59PM +0000, Jose Fonseca wrote:
>> I figured out how to not redirect stderr, but I can't figure out how to not
>> catch the exceptions for the life of me.
>>
>> There's not a single exception handler, but many.  I identified some as
>> drafted in the attached, but there are apparently more.
>>
>> They are hidden inside accessors and function decorators, and who knows what
>> more...
>>
>> Jose
>
>> diff --git a/framework/exceptions.py b/framework/exceptions.py
>> index fdd1f1f..f93dda8 100644
>> --- a/framework/exceptions.py
>> +++ b/framework/exceptions.py
>> @@ -32,43 +32,9 @@ __all__ = [
>>       'handler',
>>   ]
>>
>> -_DEBUG = bool(os.environ.get('PIGLIT_DEBUG', False))
>> -
>>
>>   def handler(func):
>> -    """Decorator function for handling errors in an entry point.
>> -
>> -    This will handle expected errors (PiglitFatalError), and unexpected errors,
>> -    either PiglitInternalErrors or PiglitExceptions, as well as handling
>> -    generic Exceptions
>> -
>> -    """
>> -
>> -    @functools.wraps(func)
>> -    def _inner(*args, **kwargs):
>> -        try:
>> -            func(*args, **kwargs)
>> -        except PiglitFatalError as e:
>> -            print('Fatal Error: {}'.format(str(e)), file=sys.stderr)
>> -            sys.exit(1)
>> -        except (PiglitInternalError, PiglitException) as e:
>> -            print('Warning: An internal exception that should have '
>> -                  'been handled was not. This is bug and should be reported.\n'
>> -                  'BUG: {}'.format(str(e)),
>> -                  file=sys.stderr)
>> -            if _DEBUG:
>> -                raise
>
> I think the behavior you want is to drop "if _DEBUG" (both here and
> below), and just raise unconditionally in these cases.
>
> If that is what you want, you have my r-b on that.

Yes, I'd wish that Python exceptions to cause piglit to terminate.  But 
I'm afraid I don't have the time to pursue this further at this moment.

If you could make it happen somehow, it would be greatly appreciated. 
As I'm sure it will save time we have any issue in the framework, by 
allowing to quickly spot and diagnose the issue.

Jose


More information about the Piglit mailing list