You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 21, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 21, 2022. It is now read-only.
just a very simple code : print ("first"), have issue:
Traceback (most recent call last):
File "\AppData\Local\LightTable\plugins\Python\py-src\ltmain.py", line 193, in handleEval
code= compile(ensureUtf(code), ensureUtf(data[2]["name"]), 'eval')
File "\AppData\Local\LightTable\plugins\Python\py-src\ltmain.py", line 50, in ensureUtf
if type(s) == unicode:
NameError: name 'unicode' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "AppData\Local\LightTable\plugins\Python\py-src\ltmain.py", line 197, in handleEval
code= compile(ensureUtf(code), ensureUtf(data[2]["name"]), 'exec')
File "\AppData\Local\LightTable\plugins\Python\py-src\ltmain.py", line 50, in ensureUtf
if type(s) == unicode:
NameError: name 'unicode' is not defined
Same problem here, are you running python 3 by chance? In that case, It seems to be because python 3 doesn't have the unicode type anymore as it's been replaced by/incorperated into the 'str' type. Is development being done on python 3 with this plugin? Would be great if it was. e2bed09
If you want to hotfix it for now, you can simply replace the "unicode" by "str" on line 51 of the /py-src/ltmain.py file in the python plugin directory for Light Table. Don't forget to switch it back if you ever need to use python 2 ;)
It would be great, if there was functionality for doing this which was backwards compatible, or if you could switch in your settings between python2 and python3 evaluation, that would then select the corresponding plugin to run. I don't know which design would be preferred by the Light Table team however.
Reacted by Adam Cameron, Maxime Joanis, ghsgz, Anil Maddala, ClarkYang, Dattatreya and Maxim Kiyaev
Hi,
I'm completely new to LightTable and I might be wrong but I think I found a better fix that I just submitted
defensureUtf(s, encoding='utf8'):
"""Converts input to unicode if necessary. If `s` is bytes, it will be decoded using the `encoding` parameters. This function is used for preprocessing /source/ and /filename/ arguments to the builtin function `compile`. """# In Python2, str == bytes.# In Python3, bytes remains unchanged, but str means unicode# while unicode is not defined anymoreiftype(s) ==bytes:
returns.decode(encoding, 'ignore')
else:
returns
I tested it with python2.7.11 and python3.5.1 on my archlinux platform.
Then, if accepted it makes sense to rename the function to reflect its actual role,
which I did in a later commit.
@dav009 We need someone to takeover the Python plugin. As Keith pointed out, we've got potential fixes, but we have no-one to review and merge them. Even if you (or anyone else) doesn't want to take responsibility for the entirety of Python in LT or even just the LT Python plugin, I'm willing to merge PRs if enough commenters agreed on which ones should be merged.
Reacted by Ian Channing, Gregory Gerasev and Ramu Rajasekharan
LightTable is not dead, but the current python plugin maintainer, @stemd, appears to be inactive or otherwise not available. That said, we are probably in need of someone to actively work on the plugin.
I am not familiar with Python, but there is an open pull request that may contain a fix #47. If anyone is able to review or test the fix then I am happy to merge it in.
I managed to get Python3 working on my setup, idea was to test that on all platforms (Linux, Mac, Windows) before merging.
Also there was an idea to detect Python2 and Python3, and to adapt automatically, but ClojureScript is not so straightforward, and not all code is well commented.
@stemd, would you be able to point out the poorly documented Clojurescript files or code that are relevant to you? Happy to bump them up in the list of things to document soon.
Activity
berendbaas commentedon Feb 19, 2015
Same problem here, are you running python 3 by chance? In that case, It seems to be because python 3 doesn't have the unicode type anymore as it's been replaced by/incorperated into the 'str' type. Is development being done on python 3 with this plugin? Would be great if it was.
e2bed09
ossplus commentedon Feb 20, 2015
yes. python3.4
berendbaas commentedon Feb 20, 2015
If you want to hotfix it for now, you can simply replace the "unicode" by "str" on line 51 of the /py-src/ltmain.py file in the python plugin directory for Light Table. Don't forget to switch it back if you ever need to use python 2 ;)
It would be great, if there was functionality for doing this which was backwards compatible, or if you could switch in your settings between python2 and python3 evaluation, that would then select the corresponding plugin to run. I don't know which design would be preferred by the Light Table team however.
ergodicbreak commentedon Feb 22, 2015
@berendbaas maybe this would be a reasonable compatible fix?
berendbaas commentedon Feb 22, 2015
@ergodicbreak Seems like a good way to go to me.
kenny-evitt commentedon Jun 28, 2015
@berendbaas @ergodicbreak – care to comment on PR #28?
Fixing issue LightTable#24 -NameError: name 'unicode' is not defined
RockyRoad29 commentedon Jan 15, 2016
Hi,
I'm completely new to LightTable and I might be wrong but I think I found a better fix that I just submitted
I tested it with python2.7.11 and python3.5.1 on my archlinux platform.
Then, if accepted it makes sense to rename the function to reflect its actual role,
which I did in a later commit.
dav009 commentedon Feb 5, 2016
Is this issue moving at all? It seems quite relevant yet quite inactive
keith-hall commentedon Feb 5, 2016
@dav009 see #47 (comment) for why no Python fixes are being merged at the moment
kenny-evitt commentedon Feb 5, 2016
@dav009 We need someone to takeover the Python plugin. As Keith pointed out, we've got potential fixes, but we have no-one to review and merge them. Even if you (or anyone else) doesn't want to take responsibility for the entirety of Python in LT or even just the LT Python plugin, I'm willing to merge PRs if enough commenters agreed on which ones should be merged.
meownoid commentedon Sep 7, 2016
Still not working in 8.0.1. Is LT dead?
sbauer322 commentedon Sep 7, 2016
Sorry to hear this is still a problem, @meownoid.
LightTable is not dead, but the current python plugin maintainer, @stemd, appears to be inactive or otherwise not available. That said, we are probably in need of someone to actively work on the plugin.
I am not familiar with Python, but there is an open pull request that may contain a fix #47. If anyone is able to review or test the fix then I am happy to merge it in.
stemd commentedon Sep 8, 2016
I managed to get Python3 working on my setup, idea was to test that on all platforms (Linux, Mac, Windows) before merging.
Also there was an idea to detect Python2 and Python3, and to adapt automatically, but ClojureScript is not so straightforward, and not all code is well commented.
sbauer322 commentedon Sep 8, 2016
@stemd, would you be able to point out the poorly documented Clojurescript files or code that are relevant to you? Happy to bump them up in the list of things to document soon.
Merge pull request #47 from RockyRoad29/Python3Unicode
Aurora11111 commentedon Aug 27, 2018
in python2.x:
item = unicode(item, 'utf-8')
in python3.x:
item = str(item.encode('utf-8'))
omkarvijay5 commentedon Feb 6, 2019
Python 3 renamed the unicode type to str, the old str type has been replaced by bytes
renaming unicode occurrences with str worked for me