Python sys.exc_traceback() Examples
The following are 30
code examples of sys.exc_traceback().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sys
, or try the search function
.
Example #1
Source File: cfmfile.py From Computable with MIT License | 6 votes |
def __init__(self, path = None): self.version = 1 self.fragments = [] self.path = path if path is not None and os.path.exists(path): currentresref = Res.CurResFile() resref = Res.FSpOpenResFile(path, 1) Res.UseResFile(resref) try: try: data = Res.Get1Resource('cfrg', 0).data except Res.Error: raise Res.Error, "no 'cfrg' resource found", sys.exc_traceback finally: Res.CloseResFile(resref) Res.UseResFile(currentresref) self.parse(data) if self.version != 1: raise error, "unknown 'cfrg' resource format"
Example #2
Source File: test_compare.py From ironpython2 with Apache License 2.0 | 6 votes |
def verifyStderr(self, method, successRe) : """ Call method() while capturing sys.stderr output internally and call self.fail() if successRe.search() does not match the stderr output. This is used to test for uncatchable exceptions. """ stdErr = sys.stderr sys.stderr = StringIO() try: method() finally: temp = sys.stderr sys.stderr = stdErr errorOut = temp.getvalue() if not successRe.search(errorOut) : self.fail("unexpected stderr output:\n"+errorOut) if sys.version_info < (3, 0) : # XXX: How to do this in Py3k ??? sys.exc_traceback = sys.last_traceback = None
Example #3
Source File: test_exceptions.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_str2(self): # verify we can assign to sys.exc_* sys.exc_traceback = None sys.exc_value = None sys.exc_type = None self.assertEqual(str(Exception()), '') @skipUnlessIronPython() def test_array(self): import System try: a = System.Array() except Exception, e: self.assertEqual(e.__class__, TypeError) else:
Example #4
Source File: errors.py From kotori with GNU Affero General Public License v3.0 | 6 votes |
def traceback_get_exception(num = -1): # build error message exception_string = ''.join(traceback.format_exception_only(sys.exc_type, hasattr(sys, 'exc_value') and sys.exc_value or 'Unknown')) # extract error location from traceback if hasattr(sys, 'exc_traceback'): (filename, line_number, function_name, text) = traceback.extract_tb(sys.exc_traceback)[num] else: (filename, line_number, function_name, text) = ('-', '-', '-', '-') error = { 'message': exception_string, 'location': { 'filename': filename, 'line_number': line_number, 'function_name': function_name, 'text': text, } } return error
Example #5
Source File: UTscapy.py From CyberScan with GNU General Public License v3.0 | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #6
Source File: test_compare.py From ironpython2 with Apache License 2.0 | 6 votes |
def verifyStderr(self, method, successRe) : """ Call method() while capturing sys.stderr output internally and call self.fail() if successRe.search() does not match the stderr output. This is used to test for uncatchable exceptions. """ stdErr = sys.stderr sys.stderr = StringIO() try: method() finally: temp = sys.stderr sys.stderr = stdErr errorOut = temp.getvalue() if not successRe.search(errorOut) : self.fail("unexpected stderr output:\n"+errorOut) if sys.version_info < (3, 0) : # XXX: How to do this in Py3k ??? sys.exc_traceback = sys.last_traceback = None
Example #7
Source File: test_compare.py From BinderFilter with MIT License | 6 votes |
def verifyStderr(self, method, successRe) : """ Call method() while capturing sys.stderr output internally and call self.fail() if successRe.search() does not match the stderr output. This is used to test for uncatchable exceptions. """ stdErr = sys.stderr sys.stderr = StringIO() try: method() finally: temp = sys.stderr sys.stderr = stdErr errorOut = temp.getvalue() if not successRe.search(errorOut) : self.fail("unexpected stderr output:\n"+errorOut) if sys.version_info < (3, 0) : # XXX: How to do this in Py3k ??? sys.exc_traceback = sys.last_traceback = None
Example #8
Source File: test_compare.py From BinderFilter with MIT License | 6 votes |
def verifyStderr(self, method, successRe) : """ Call method() while capturing sys.stderr output internally and call self.fail() if successRe.search() does not match the stderr output. This is used to test for uncatchable exceptions. """ stdErr = sys.stderr sys.stderr = StringIO() try: method() finally: temp = sys.stderr sys.stderr = stdErr errorOut = temp.getvalue() if not successRe.search(errorOut) : self.fail("unexpected stderr output:\n"+errorOut) if sys.version_info < (3, 0) : # XXX: How to do this in Py3k ??? sys.exc_traceback = sys.last_traceback = None
Example #9
Source File: cfmfile.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def __init__(self, path = None): self.version = 1 self.fragments = [] self.path = path if path is not None and os.path.exists(path): currentresref = Res.CurResFile() resref = Res.FSpOpenResFile(path, 1) Res.UseResFile(resref) try: try: data = Res.Get1Resource('cfrg', 0).data except Res.Error: raise Res.Error, "no 'cfrg' resource found", sys.exc_traceback finally: Res.CloseResFile(resref) Res.UseResFile(currentresref) self.parse(data) if self.version != 1: raise error, "unknown 'cfrg' resource format"
Example #10
Source File: UTscapy.py From isip with MIT License | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #11
Source File: test_actors.py From calvin-base with Apache License 2.0 | 6 votes |
def test_actors(self): test_pass = [] test_fail = {} no_test = [] for actor in self.actors: aut = self.actors[actor] if aut == "no_test": no_test.append(actor) continue try: self.test_actor(actor, aut) test_pass.append(actor) except AssertionError as e: test_fail[actor] = e.message except Exception as e: self.illegal_actors[actor] = str(e) + '\n' + ''.join( traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) return {'pass': test_pass, 'fail': test_fail, 'skipped': no_test, 'errors': self.illegal_actors, 'components': self.components}
Example #12
Source File: test_compare.py From oss-ftp with MIT License | 6 votes |
def verifyStderr(self, method, successRe) : """ Call method() while capturing sys.stderr output internally and call self.fail() if successRe.search() does not match the stderr output. This is used to test for uncatchable exceptions. """ stdErr = sys.stderr sys.stderr = StringIO() try: method() finally: temp = sys.stderr sys.stderr = stdErr errorOut = temp.getvalue() if not successRe.search(errorOut) : self.fail("unexpected stderr output:\n"+errorOut) if sys.version_info < (3, 0) : # XXX: How to do this in Py3k ??? sys.exc_traceback = sys.last_traceback = None
Example #13
Source File: test_compare.py From oss-ftp with MIT License | 6 votes |
def verifyStderr(self, method, successRe) : """ Call method() while capturing sys.stderr output internally and call self.fail() if successRe.search() does not match the stderr output. This is used to test for uncatchable exceptions. """ stdErr = sys.stderr sys.stderr = StringIO() try: method() finally: temp = sys.stderr sys.stderr = stdErr errorOut = temp.getvalue() if not successRe.search(errorOut) : self.fail("unexpected stderr output:\n"+errorOut) if sys.version_info < (3, 0) : # XXX: How to do this in Py3k ??? sys.exc_traceback = sys.last_traceback = None
Example #14
Source File: UTscapy.py From dash-hack with MIT License | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #15
Source File: UTscapy.py From dash-hack with MIT License | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #16
Source File: environment.py From dot15926 with GNU Lesser General Public License v3.0 | 6 votes |
def ExecutePythonString(self, text): try: try: return eval(text, globals(), self.GetLocals()) except SyntaxError: tb = sys.exc_traceback if tb.tb_next is None: exec text in self.GetLocals() else: raise except NameError as e: tb = sys.exc_traceback if tb.tb_next and tb.tb_next.tb_next is None: log("Error: {0}\n", e.args[0]) else: raise
Example #17
Source File: UTscapy.py From dash-hack with MIT License | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #18
Source File: inherit_hr_employee.py From LibrERP with GNU Affero General Public License v3.0 | 6 votes |
def _get_assigned_letters(self, cr, uid, ids, prop, unknow_none, context=None): if not len(ids): return {} model_name = super(hr_employee, self)._name res = [] try: for id in ids: letter_ids = [] ref_ids = self.pool['letter.ref'].search(cr, uid, [('int_ref', '=', model_name + ',' + str(id))], context=context) if ref_ids: for ref in self.pool['letter.ref'].read(cr, uid, ref_ids, context=context): letter_ids.append(ref['letter_id'][0]) res.append((id, letter_ids)) except Exception, e: _logger.error(repr(traceback.extract_tb(sys.exc_traceback)))
Example #19
Source File: UTscapy.py From POC-EXP with GNU General Public License v3.0 | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #20
Source File: UTscapy.py From mptcp-abuse with GNU General Public License v2.0 | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #21
Source File: UTscapy.py From smod-1 with GNU General Public License v2.0 | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #22
Source File: UTscapy.py From CVE-2016-6366 with MIT License | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #23
Source File: test_traceback.py From medicare-demo with Apache License 2.0 | 5 votes |
def na_jython_test_members(self): # Covers Python/structmember.c::listmembers() try: 1/0 except: import sys sys.exc_traceback.__members__
Example #24
Source File: jython_compat.py From python-for-android with Apache License 2.0 | 5 votes |
def formatExceptionTrace(e): newStr = "".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) return newStr
Example #25
Source File: jython_compat.py From python-for-android with Apache License 2.0 | 5 votes |
def formatExceptionTrace(e): newStr = "".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) return newStr
Example #26
Source File: jython_compat.py From python-for-android with Apache License 2.0 | 5 votes |
def formatExceptionTrace(e): newStr = "".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) return newStr
Example #27
Source File: compat.py From filmkodi with Apache License 2.0 | 5 votes |
def formatExceptionTrace(e): newStr = "".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) return newStr
Example #28
Source File: _pydev_inspect.py From filmkodi with Apache License 2.0 | 5 votes |
def currentframe(): """Return the frame object for the caller's stack frame.""" try: raise 'catch me' except: return sys.exc_traceback.tb_frame.f_back #@UndefinedVariable
Example #29
Source File: traceback.py From medicare-demo with Apache License 2.0 | 5 votes |
def print_exc(limit=None, file=None): """Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'. (In fact, it uses sys.exc_info() to retrieve the same information in a thread-safe way.)""" if file is None: file = sys.stderr try: etype, value, tb = sys.exc_info() print_exception(etype, value, tb, limit, file) finally: etype = value = tb = None
Example #30
Source File: test_traceback.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def na_jython_test_members(self): # Covers Python/structmember.c::listmembers() try: 1/0 except: import sys sys.exc_traceback.__members__