<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2014-11-25 12:29 GMT+01:00 Stefan Bucur <span dir="ltr"><<a href="mailto:stefan.bucur@gmail.com" target="_blank">stefan.bucur@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br><br><div class="gmail_quote"><span>On Tue Nov 18 2014 at 2:01:46 PM Dave Halter <<a href="mailto:davidhalter88@gmail.com" target="_blank">davidhalter88@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Stefan<br><br>I'm playing with this as well in Jedi. I'm pretty far with flow analysis and AttributeErrors. (This includes everything you mention above except integer division by zero). Would be easy to implement in Jedi, though. I just have different priorities, at the moment.<br><br>If you have some time on your hands you can watch my EuroPython talk about this: <a href="https://www.youtube.com/watch?v=DfVHSw0iOsk" target="_blank">https://www.youtube.com/watch?v=DfVHSw0iOsk</a> I'm also glad to skype (gaukler_) if you're interested. Jedi is not well known for doing static analysis. But it's my goal to change this now.<br></div></div></blockquote><div><br></div></span><div>Thanks Dave for the pointer. I watched your talk and had a look at Jedi's code — this is quite nice and would indeed be great to better expose the static analysis potential of the framework.</div><div><br></div><div>What I'm trying to achieve is something a bit different. My goal is to reuse as much as possible the "implicit specs" of the interpreter itself (CPython), as opposed to implementing them again in my analysis tool.</div><div><br></div><div>W<span style="line-height:19.8px">e already have an execution engine that uses the interpreter to automatically explore multiple paths through a piece of Python code. You can read here the academic paper, with case studies for Python and Lua:  </span><span style="line-height:19.8px"><a href="http://dslab.epfl.ch/pubs/chef.pdf" target="_blank">http://dslab.epfl.ch/pubs/chef.pdf</a></span></div></div></blockquote><div><br></div><div>Stefan, I haven't read the full paper (but most of it). Interesting stuff! Are you doing any "argument propagation" or are you simply looking at a function without argument knowledge?<br><br></div><div>How do you does your output look like? Can you give us a real world example (maybe simplejson)? Would be really interesting.<br></div><div><br></div><div>BTW: I remember asking the same question that you asked here in the beginning: "What are your most typical mistakes that you would like a static analysis tool pick up?" <a href="https://github.com/davidhalter/jedi/issues/408">https://github.com/davidhalter/jedi/issues/408</a> The first maybe 10 answers might interest you.<br><br></div><div>~ Dave<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div><span style="line-height:19.8px"><br></span></div><div><span style="line-height:19.8px">I'm now working on extending this technique to other types of analyses and I'm trying to determine the most relevant types of analyses and checks for Python. So far, I conclude that type inference would serve multiple purposes and is on the top of my list.</span></div><span><font color="#888888"><div><span style="line-height:19.8px"><br></span></div><div><span style="line-height:19.8px">Stefan</span></div></font></span><span><div><span style="line-height:19.8px"><br></span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_extra"><br><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">2014-11-17 18:18 GMT+01:00 Stefan Bucur <span dir="ltr"><<a href="mailto:stefan.bucur@gmail.com" target="_blank">stefan.bucur@gmail.com</a>></span>:<br></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote">I'm developing a Python static analysis tool that flags common programming errors in Python programs. The tool is meant to complement other tools like Pylint (which perform checks at lexical and AST level) by going deeper with the code analysis and keeping track of the possible control flow paths in the program (path-sensitive analysis).<div><br></div><div>For instance, a path-sensitive analysis detects that the following snippet of code would raise an AttributeError exception:</div><div><br></div><div>if object is None: # If the True branch is taken, we know the object is None</div><div>  object.doSomething() # ... so this statement would always fail</div><div><br></div><div>I wanted first to tap into people's experience and get a sense of what common pitfalls in the language & its standard library such a static checker should look for. Just as an example of what I mean, here [1] is a list of static checks for the C++ language, as part of the Clang static analyzer project.</div><div><br></div><div>My preliminary list of Python checks is quite rudimentary, but maybe could serve as a discussion starter:</div><div><br></div><div>* Proper Unicode handling (for 2.x)</div><div>  - encode() is not called on str object</div><div>  - decode() is not called on unicode object</div><div>* Check for integer division by zero</div><div>* Check for None object dereferences</div><div><br></div><div>Thanks a lot,</div><div>Stefan Bucur</div><div><br></div><div>[1] <a href="http://clang-analyzer.llvm.org/available_checks.html" target="_blank">http://clang-analyzer.llvm.org/available_checks.html</a></div><div><br></div></div>
<br></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">_______________________________________________<br>
code-quality mailing list<br>
<a href="mailto:code-quality@python.org" target="_blank">code-quality@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/code-quality" target="_blank">https://mail.python.org/mailman/listinfo/code-quality</a><br>
<br></blockquote></div></div></blockquote></span></div>
</blockquote></div><br></div></div>