Python: How can I know which exceptions might be thrown from a method call -


What is the exception (coding time) a way to expect when executing Python code? I end up getting the exception class 90% at the end, because I do not know how the exception can be thrown (and do not tell me to read the document.) Exceptions can sometimes be propagated deeply. The documents are not updated or correct times). Is there any type of device to check this? (Like reading Python codes and Libs)?

I think a solution can only be unhealthy because the lack of stable typing rules.

I do not know of some equipment that examines exceptions, but you can come up with your own equipment (with a good chance to play with stable analysis) with your own device .

As the first attempt, you can write a function by creating an AST, which finds all the lifting nodes, and then tries to understand similar patterns of increasing exceptions.

Let the command be the following program:

  x = '' '\ if f (as if calling a constructor) X): Extend the IOError (Error  compiler  Create AST using the package: 

  tree = compiler.parse ( X)  

then Define the visitor class:

  Class raise the visitor (object): def __init __ (self): Self.nodes = [] Travel to DIF (self , N): self.nodes.append (n)  

and collecting AST lift nodes:

  v = RaiseVisitor (), Compiler.walk (tree, V)> gt; print v.nodes (callfunk (name ('ioRR'), [gate (name ('error'), 'nout'), cost ( 'No', no one else), none, no one) raise (name ('e', nobody, none),]  

You can issue symbols by using compiler symbol tables, analyzing data dependencies, etc. Or you can also guess that CallFunc (name ('IOError', ...) "must definitely raise IOError for quick practical results Quite fine :)


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -