Python 3 Generator/Reverse support

Hey,

I’m interested in introducing the software to my company’s workflow, but the very outdated support for Python 3 (including reversing from type hints) is a deal breaker to me. I’ve seen an old question about it - Python 3.x does not exist in the list - what’s the progress?

Best,
Prem

1 Like

Visual Paradigm in my opinion is a great product, but its Python reversing gives me headaches. I frequently have gotten (presumed) syntax errors or even internal parsing errors. I entered several tickets on Python reversing in the past. Often the problem would be fixed quickly, but sometimes not, or other bugs would be introduced while fixing the initial one.

When I ran into reversing errors again the last days, I created a small helper script, now at https://hg.sr.ht/~sschwarzer/python_skeleton . Tickets can be entered at https://todo.sr.ht/~sschwarzer/python_skeleton . This script – at least at the moment – won’t give you the types from the type hints, but at least it should get the code (the stub code generated by the script) reversed.

Dear Visual Paradigm team, I have the following suggestions:

  • Please support reversing for Python 2 and 3 as two separate options. Don’t try to combine Python 2 and 3 in a common “Python code”.

  • Use the official grammars from the Python project or existing Python parsers for Java. Don’t fix individual reversing bugs case by case.

  • For testing, try to reverse the standard library for each Python version. If this succeeds without errors, I think it’s very likely that almost all source code in the wild will be parsed correctly as well. If you want your code to be even more robust, include the unit tests for the respective Python versions in your reversing tests.

  • Although Python 2 support from the CPython team officially ends on 2020-01-01, this doesn’t mean you shouldn’t invest time in Python 2 reversing support. Many projects have delayed their migration to Python 3, and when they’ll tackle it eventually, they’ll be very thankful if they can reverse their legacy Python 2 code to get an overview for the Python 3 migration.

Best regards,
Stefan

1 Like

I also had to abandon Visual Paradigm because of its lack of support for Python type hints, too.

A little more info if VP ever wants to do better…

  • Documentation of the syntax of Python type hints is at https://www.python.org/dev/peps/pep-0484/
  • In particular, I had trouble with annotating the return type of a method; the log shows "invalid syntax’

Here is a minimal snippet of code to produce the error:

class Foo:
    def bar(self) -> bool:
        return True

Hi, I would like to let you know the Python reverse engineering problem has been fixed and please update the software to latest patch build (20200230cf or later) to get the problem fixed. Details about update to latest patch can be found at

  • Please make sure you have pressed the “Update to latest patch” button on the left hand side of the dialog right after launching the update program

Feel free to contact me if you require any further information.

I am no longer getting that problem; great! Thank you; it was remarkably quick work.

(Unfortunately, I’m getting other errors which don’t seem related to this topic, so I’ll contact separately about that.)

After updating from VP 16.0 to 16.1, I can now somewhat use Instant Code Reversal for our fully type-hinted Python project :+1:

However, some issues remain:

  1. I get the following error message for various source files: [17:05:17] [Error] <redacted>.py: Internal error:java.lang.ClassCastException: class v.bdj.d cannot be cast to class v.bdj.bj (v.bdj.d and v.bdj.bj are in unnamed module of loader 'app').

  2. Unpacking lists as method parameters is falsely recognized as invalid syntax:

    my_method(*param_list)
    
  3. The following code is falsely recognized as invalid syntax (however, I do not know what excatly causes this):

    print(
             "Hello World",
             file=sys.stderr,
         )
    
  4. Using **kwargs after a keyword argument is falsely recognized as non-keyword argument following keyword:

    my_method(keyword_param=some_value, **kwargs)
    
  5. Raising exceptions from None is sometimes recognized as invalid syntax:

    raise MyException("Error!") from None
    

    However, this is quite inconsistent, as it works for some files and does not work for others.

Can someone tell me if these work in VP 16.3?
We have an academic license up to 16.1, so updating just for testing is not an option.
If these issues are resolved in 16.3, I will try to get our license updated.

Hi fniehaus,

Thank you for your reply. I am going to forward your message to our development team to study. When there is any news, I will let you know.

Best regards,
Jick Yeung