slimit broken on Python 3. #64
![@doerwalter](https://i-blog.csdnimg.cn/blog_migrate/4094e2b4cbc7e8ad1d45aada4e4abda0.png)
doerwalter commented
on 13 Jan 2014
![@lelit](https://i-blog.csdnimg.cn/blog_migrate/9fb5a7f85fed0f1fd1ab0c8e254a6e07.jpeg)
lelit commented
on 9 Feb 2014
![@Alexey-T](https://i-blog.csdnimg.cn/blog_migrate/78ee99f4d0adb906878fcf647ba23a61.png)
Alexey-T commented
on 22 Feb 2014
Hello.Where can I download PY3k ready Slimit version? Is some URL avail?
![@lelit](https://i-blog.csdnimg.cn/blog_migrate/9fb5a7f85fed0f1fd1ab0c8e254a6e07.jpeg)
I successfully used my own fork, see
https://github.com/rspivak/slimit/pull/65.
![@Alexey-T](https://i-blog.csdnimg.cn/blog_migrate/78ee99f4d0adb906878fcf647ba23a61.png)
Alexey-T commented
on 22 Feb 2014
I see err with Py3.2 (embedded, can't use 3.3). I need 3.3 or...?
Python 3.2.5 (default, May 15 2013, 23:06:03) [MSC v.1500 32 bit (Intel)]
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "D:\S\Py\syn_js_minifier\__init__.py", line 8, in <module>
import slimit
File "D:\S\Py\syn_js_minifier\slimit\__init__.py", line 27, in <module>
from slimit.minifier import minify
File "D:\S\Py\syn_js_minifier\slimit\minifier.py", line 31, in <module>
from slimit import mangler
File "D:\S\Py\syn_js_minifier\slimit\mangler.py", line 27, in <module>
from slimit.scope import SymbolTable
File "D:\S\Py\syn_js_minifier\slimit\scope.py", line 34, in <module>
from slimit.lexer import Lexer
File "D:\S\Py\syn_js_minifier\slimit\lexer.py", line 29, in <module>
from slimit.unicode_chars import (
File "D:\S\Py\syn_js_minifier\slimit\unicode_chars.py", line 33
u'[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6'
^
SyntaxError: invalid syntax
![@lelit](https://i-blog.csdnimg.cn/blog_migrate/9fb5a7f85fed0f1fd1ab0c8e254a6e07.jpeg)
File "D:\S\Py\syn_js_minifier\slimit\unicode_chars.py", line 33 u'[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6' ^ SyntaxError: invalid syntax
Yes, you need Python 3.3: the u'XY' syntax has been reintroduced in that version to make iteasier sharing code between the 2.x line and >=3.3.
![@doerwalter](https://i-blog.csdnimg.cn/blog_migrate/4094e2b4cbc7e8ad1d45aada4e4abda0.png)
doerwalter commented
on 27 Mar 2014
It seems that with ply 3.4 and slimit 0.8.1 the slice handling is the only remaining problem on Python 3.3. I can monkeypath around that problem like this:
from ply import yacc
import slimit
def __getitem__(self,n):
if isinstance(n, slice):
return self.__getslice__(n.start, n.stop)
if n >= 0: return self.slice[n].value
else: return self.stack[n].value
yacc.YaccProduction.__getitem__ = __getitem__
s = "function x(){switch (x) { case 17: break; case 23: break; }} "
print(slimit.minify(s))
![@delijati](https://i-blog.csdnimg.cn/blog_migrate/a5286797b53a9664fe9e6dc50b40f7f3.jpeg)
delijati commented
on 19 Nov 2014
I also tried the ply
version from github with some more errors. Maynbe you can fork ply with your current fix and relase it under a another name ... ugly i know
SyntaxError: Unexpected token (RBRACE, '}') at 1:1730813 between LexToken(ID,'disabled',1,1730804) and LexToken(RPAREN,')',1,1730814)
![@lelit](https://i-blog.csdnimg.cn/blog_migrate/9fb5a7f85fed0f1fd1ab0c8e254a6e07.jpeg)
lelit commented
on 20 Nov 2014
Do you mean that you tried mine fork of ply, and that gave you the reported error?
![@delijati](https://i-blog.csdnimg.cn/blog_migrate/a5286797b53a9664fe9e6dc50b40f7f3.jpeg)
delijati commented
on 20 Nov 2014
No sorry for the confusion,i tried the 3.5 vanilla version.
jleclanche referenced this issue from a commit in jleclanche/MediaCrush
on 31 Jan
2afeb1f |
下面是ply的简介
I'm trying to use slimit on Python 3 and get the following exception:
The problem seems to be that in Python 3 slices are handled via
__getitem__
not via__getslice__
.