-
Notifications
You must be signed in to change notification settings - Fork 136
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
Conversation
I think QGIS 3 might be implementing the 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. |
Yes, it only happen in QGIS.
Your idea of using another try except also seems good and simple.
but I would suggest putting whole 'else' block in 'try' to be safe.
Thanks & Regards
Shiva Reddy K.
Scientist/Engineer 'SC'
Indian Institute of Remote Sensing,
Indian Space Research Organisation
Department of Space
4-Kalidas Road
Dehradun
mobile: 8791806093
…On Thu, Mar 8, 2018 at 1:57 AM, ukanga ***@***.***> wrote:
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 = chrelse:
# 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
<#161> exception on my end once
I get a hold of a windows VM and install qgis on it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#179 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFZECMq-pNFenuW65V7Rd8sj5iOXG4flks5tcELJgaJpZM4SeUiI>
.
|
Fix #161
If unicode does not throw exception , then check the python version so that this problem can be solved.