abulka / pynsource

Reverse engineer Python source code into UML
http://pynsource.com
283 stars 40 forks source link

crash parsing Python **dict syntax #65

Closed tinix84 closed 4 years ago

tinix84 commented 4 years ago

if I use the win10 1.3.5 with this file https://github.com/tinix84/pyplecs/blob/master/pyplecs/pyplecs.py it enter in endless loop. what to do to debug it?

abulka commented 4 years ago

Hi. The code needs to compile in order to be parsed correctly.

That code you refer to won’t compile because it’s indentation is all messed up, at least looking at the code via GitHub.

tinix84 commented 4 years ago

Thanks can you please be more precise? the file run in VScode or in terminal, shoud I change something?

abulka commented 4 years ago

Hi - contrary to what I initially said, the code you refer to is actually formatted OK - it didn't appear formatted correctly when I initially browsed it in GitHub using my iPad Pro - probably some bug in Safari for iPad. Looks OK from a normal browser and when I downloaded that file.

Yes, I can confirm the code in module pyplecs.py is indeed causing a crash in Pynsource. I will investigate. One laborious way you can figure out which line is causing the problem is to progressively edit and eliminate code in that module till the offending syntax is determined.

Another way is to turn on parsing logging which I will document in the future, as I'll have to re-remember how to enable it!

FYI the online version of Pynsource (GitUML) parses this code OK straight from GitHub - you may be interested in GitUML as it specialises in your use case of parsing code from GitHub repos e.g. see https://www.gituml.com/viewz/100

gituml image svg

abulka commented 4 years ago

Small update - seems Pynsource cannot understand the syntax

varin = {**self.optStruct['ModelVars'], **data}

on line 197. By commenting out that single line, the file pyplecs.py parses OK. I'll need to improve the parser - are you running the Pynsource windows binary or running from source? I can push a source code fix in Pynsource to GitHub pretty quickly.

abulka commented 4 years ago

Latest version of source code I just commited has better error reporting - you will get the line number and offending line of syntax displayed, plus an indication of where the log file is containing more information. a3baa972be687809fc64a3ba65234874c11d171e

Also now parses the above syntax without an error. 2728df81bf345906a042cc59c8480238bc95e09f

tinix84 commented 4 years ago

thanks for your support! it works with github version :)