cyberphone/json-canonicalization

[Python] Support for Python 2.7

AnasMK opened this issue · 7 comments

Hey there,

Is there any support for Python 2.7

Hi @AnasMK, there once was support for Python 2.7 but I removed when the Python authors decided to halt the 2.7 branch. On the other hand, the existing implementation is very basic so it might very well run in 2.7 as well. The test programs would verify if that is the case.
Regards,
@cyberphone (Anders)

Hi @cyberphone, thank you, I really appreciate your quick replay.

I have tried to run tests using python 2.7, there were some syntax errors in Canonicalize.py
I did these changes:

  1. had to remove bare asterisk argument in JSONEncoder constructor, not supported in 2.7
  2. had to change yeild from statement to for loop in 5 places
    • lines: 346, 425, 449, 451, 459
    • All of them have been replaced by this for loop
       for bar in foo: 
           yield bar

After these changes verify-canonicalization.py produce this error:

TypeError: Object of type 'unicode' is not JSON serializable

Any help to resolve this issue.
Thank you.

Hi @cyberphone, If you have a local copy of the Python 2.7 branch, it will be much appreciated to upload it again 🙏.

It seems that I lost that branch during a restructuring. Usually I put unsupported stuff in the "historical" repo but this time not 😔

Hi,
Thanks for your support @cyberphone, I had successfully ported Python3 code to Python2.7.

  • verify-numbers.py passed the initial tests, still needs to test with the large text file
  • verify-canonicalization.py passed all the tests

For anyone is interested in Python 2.7 version I have pushed the code on this Forked repository

@cyberphone, Thank you again for your efforts with this repo.

Thanks and Congratulations!
I will update my JCS info with your implementation.