xmlutils.py icon indicating copy to clipboard operation
xmlutils.py copied to clipboard

SyntaxError: invalid syntax (related to literal string)

Open reikred opened this issue 7 years ago • 6 comments

When I run xmltable2csv I get the following error message"

File "/usr/lib/python3.4/site-packages/xmlutils/console.py", line 20 """ ^ SyntaxError: invalid syntax

The offending code is the triple-double quoted string literal as follows

def run_xml2sql(): print """xml2sql by Kailash Nadh (http://nadh.in) --help for help

"""

What am I doing wrong here? My python is version 3.4, as you can see. I feel I must be making some basic compatibility mistake or some such, as this can not possibly be a real syntax errror, can it?

reikred avatar Apr 09 '17 03:04 reikred

@reikred Thank you for bug report. Unfortunately, xmltuils is not yet compatible with Python 3. You should be able to use it with Python 2.6 or 2.7.

ChillarAnand avatar Apr 09 '17 03:04 ChillarAnand

I see. Yes, that is the problem, and it must be a common one. Should the python version not be checked when installing?

I did some web search and found a construct that supposedly should be included in setup.py, but on my system it was not recognized and caused an error. What I tried was the syntax python_requires='>=2.6,<=2.7',

The package maintainers may perhaps know better how to do this?

Reference: http://stackoverflow.com/a/40300957/3854366 http://setuptools.readthedocs.io/en/latest/setuptools.html?highlight=python_requires#new-and-changed-setup-keywords

reikred avatar Apr 09 '17 18:04 reikred

If the issue lies with print statements only then you can change the format and it should run fine. Eg - Change print """etc random information """ to print("""etc random information """)

This will take care of the print statement related issues. Also, can anyone tell me what other issues are there with the code that makes it incompatible with Python3.

ankpotter avatar Dec 29 '17 22:12 ankpotter

I guess changing print statements and iterators should do. You can pass codebase through 2to3 tool and it will take care of all this basic changes.

ChillarAnand avatar Dec 30 '17 07:12 ChillarAnand

https://github.com/knadh/xmlutils.py/commit/11da2f8061db1ebad3e71305a41e994f4c47db4b This should address the print() issue.

knadh avatar Jan 03 '18 09:01 knadh

Thanks for the fix!

On Wed, Jan 3, 2018 at 1:32 AM, Kailash Nadh [email protected] wrote:

11da2f8 https://github.com/knadh/xmlutils.py/commit/11da2f8061db1ebad3e71305a41e994f4c47db4b This should address the print() issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/knadh/xmlutils.py/issues/37#issuecomment-354969044, or mute the thread https://github.com/notifications/unsubscribe-auth/AKWa28OzpWeAMt39kZmBkqz2H_Iuw2Lyks5tG0kRgaJpZM4M35yT .

reikred avatar Jan 05 '18 18:01 reikred