Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check python version to solve unichr not defined problem #179

Merged
merged 5 commits into from
Mar 8, 2018

Conversation

shivareddyiirs
Copy link
Contributor

Fix #161
If unicode does not throw exception , then check the python version so that this problem can be solved.

@shivareddyiirs
Copy link
Contributor Author

@ukanga
Thanks for your comment. if this pull request is merged, it would be great help for develpers using pyxform in python 3 but having similar issue #161.

@ukanga
Copy link
Contributor

ukanga commented Mar 7, 2018

I think QGIS 3 might be implementing the unicode() function in python 3 or it gets injected somehow. On python 3 every version I have tested, if unicode() results in the NameError exception, so will the unichr() function. This may be the reason, despite us testing in python 2.7 to 3.6 on windows we still don't get this issue.

try:
    unicode("str")
except NameError:
    # Python 3 only should go through here
    unicode = str
    basestring = str
    unichr = chr
else:
    # python 2 only should go through here
    unicode = unicode
    basestring = basestring
    # if for whatever reason python 3 is here 
    # it means unichr was not give the same treatment as unicode and basestring above
    # probably do another try except
    try:
        unichr = unichr
    except NameError:
        unichr = chr

Could you validate that this only happens when using QGIS?

I am going to try and replicate the #161 exception on my end once I get a hold of a windows VM and install qgis on it.

@shivareddyiirs
Copy link
Contributor Author

shivareddyiirs commented Mar 8, 2018 via email

@ukanga ukanga merged commit a092ee3 into XLSForm:master Mar 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants