lczub / TestLink-API-Python-client

A Python client to use the TestLink API
104 stars 63 forks source link

Is it better to change IS_PY3 to IS_PY2 ? #114

Closed bekindtoyourself closed 5 years ago

bekindtoyourself commented 5 years ago

Hello,

IS_PY3 = sys.version_info[0] < 3
if IS_PY3:
    import xmlrpclib
    # in py 3 encodestring is deprecated and an alias for encodebytes
    # see issue #39 and compare py2 py3 doc 
    # https://docs.python.org/2/library/base64.html#base64.encodestring
    # https://docs.python.org/3/library/base64.html#base64.encodebytes
    from base64 import encodestring as encodebytes
else:
    import xmlrpc.client as xmlrpclib
    from base64 import encodebytes

Code from https://github.com/lczub/TestLink-API-Python-client/blob/master/src/testlink/testlinkapigeneric.py#L21 If sys.version_info[0] is 3, sys.version_info[0] < 3 is false. Then, IS_PY3 is false. But it is python3. I think it is better to change IS_PY3 to IS_PY2. English is not my native language. I hope I can express clearly. Thanks!

lczub commented 5 years ago

Hello Liang,

thanks for your request. I hope to have time between the years to analyse it. Till then, Luiko

lczub commented 5 years ago

Hello bekindtoyourself,

thanks finding this hidden bug. The IS_PY3 detection and if statement is now fixed.

I was wondering, why neither the py2 nor the py3 test was failing. You was right that the if statement was working as IS_PY2. Good news is, that the code loads always the correct py2 / py3 modules.

Regards Luiko

bekindtoyourself commented 5 years ago

Wonderful! I am a new person to learning Python. May be I will try to pull request in the next time, after I open the new issue. Thanks you fix it! English is not my native language. Please excuse any mistakes. Suggested improvements would be appreciated.