scrapinghub / js2xml

Convert Javascript code to an XML document
MIT License
186 stars 23 forks source link

Warnings at import time about not being able to write lex and yacc tables #9

Closed eliasdorneles closed 7 years ago

eliasdorneles commented 8 years ago

I've tried installing js2xml into a new virtualenv, and I get a bunch of warnings complaining about not being able to write lex and yacc table pyc files.

python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import js2xml
WARNING: Couldn't write lextab module <module 'js2xml.lextab' from '/home/elias/.virtualenvs/tmp-52454bac1b2a30a5/local/lib/python2.7/site-packages/js2xml/lextab.pyc'>. Won't overwrite existing lextab module
WARNING: yacc table file version is out of date
WARNING: Token 'IMPORT' defined, but not used
WARNING: Token 'BLOCK_COMMENT' defined, but not used
WARNING: Token 'ENUM' defined, but not used
WARNING: Token 'EXTENDS' defined, but not used
WARNING: Token 'LINE_COMMENT' defined, but not used
WARNING: Token 'LINE_TERMINATOR' defined, but not used
WARNING: Token 'CONST' defined, but not used
WARNING: Token 'EXPORT' defined, but not used
WARNING: Token 'CLASS' defined, but not used
WARNING: Token 'SUPER' defined, but not used
WARNING: There are 10 unused tokens
WARNING: Couldn't create <module 'js2xml.yacctab' from '/home/elias/.virtualenvs/tmp-52454bac1b2a30a5/local/lib/python2.7/site-packages/js2xml/yacctab.pyc'>. Won't overwrite existing tabmodule

Despite this, the library still works -- it's just that the warnings are annoying. More environment info:

$ pip freeze
js2xml==0.1.2
lxml==3.5.0
ply==3.8
slimit==0.8.1
wheel==0.24.0
podolskyi commented 8 years ago

I have the same error. @eliasdorneles You resolve this?

redapple commented 8 years ago

@podolskyi, I can investigate next week only. Do you get an error? As far as I know it's a warning only, yet annoying one.

akmahaja commented 8 years ago

I am getting the same error. And when I try to parse the example in the README, I get the following error: Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/site-packages/js2xml/init.py", line 12, in parse tree = _parser.parse(text if not isinstance(text, unicode) else text.encode("utf8"), debug=debug) File "/usr/local/lib/python2.7/site-packages/js2xml/parser.py", line 34, in parse result = super(CustomParser, self).parse(text, debug=debug) File "/usr/local/lib/python2.7/site-packages/slimit/parser.py", line 93, in parse return self.parser.parse(text, lexer=self.lexer, debug=debug) File "/usr/local/lib/python2.7/site-packages/ply/yacc.py", line 331, in parse return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) File "/usr/local/lib/python2.7/site-packages/ply/yacc.py", line 1181, in parseopt_notrack tok = call_errorfunc(self.errorfunc, errtoken, self) File "/usr/local/lib/python2.7/site-packages/ply/yacc.py", line 193, in call_errorfunc r = errorfunc(token) File "/usr/local/lib/python2.7/site-packages/slimit/parser.py", line 106, in p_error self._raise_syntax_error(token) File "/usr/local/lib/python2.7/site-packages/slimit/parser.py", line 89, in _raise_syntax_error self.lexer.prev_token, self.lexer.token()) SyntaxError: Unexpected token (PERIOD, '.') at 1:24 between LexToken(LINE_TERMINATOR,'\n',1,23) and LexToken(PERIOD,'.',1,25)

redapple commented 8 years ago

@akmahaja, can you provide input JavaScript ? Ideally as another issue since this one is about the warnings on yacc tables. Thanks.

akmahaja commented 8 years ago

@redapple I used the example on the gitpage of the js2xml, but it works fine for the pages I want to parse. So either I understood it incorrectly to use the example on the README page on the git or the example in not a valid input for the js2xml.parse. Thanks

redapple commented 8 years ago

@akmahaja , I'm able to run the example from the README in a fresh virtualenv with js2xml.

It does still show the warning WARNING: Couldn't create <module 'js2xml.yacctab' from '/home/paul/.virtualenvs/js2xml/local/lib/python2.7/site-packages/js2xml/yacctab.pyc'>. Won't overwrite existing tabmodule (but it's a warning, not an error) See the console logs here: https://gist.github.com/redapple/dc5ab033a8cc0cebfe4b

Here's what I ran this against:

$ pip freeze
argparse==1.2.1
js2xml==0.1.2
lxml==3.5.0
ply==3.8
slimit==0.8.1
wsgiref==0.1.2

Can you check again your input and your installation of js2xml? If you're getting an error, can I ask you to open a seperate issue, and paste input and statements that lead to the error. Thanks.

redapple commented 8 years ago

This change should fix the warnings: https://github.com/redapple/js2xml/pull/10

redapple commented 8 years ago

Closed via https://github.com/redapple/js2xml/pull/10