earwig / mwparserfromhell

A Python parser for MediaWiki wikicode
https://mwparserfromhell.readthedocs.io/
MIT License
763 stars 75 forks source link

Syntax error in setup.py on Python 3.5 #101

Closed jayvdb closed 9 years ago

jayvdb commented 9 years ago
File "/tmp/easy_install-3vuysiu_/mwparserfromhell-0.4/setup.py", line 39

    with open("README.rst", **{'encoding':'utf-8'} if py3k else {}) as fp:

                                                    ^

SyntaxError: invalid syntax

https://travis-ci.org/jayvdb/pywikibot-core/jobs/63826402#L361

earwig commented 9 years ago

Python 3.5 has been released?

jayvdb commented 9 years ago

No final release yet, but alphas (https://www.python.org/downloads/release/python-350a4/) and travis allows testing against nightly builds.

earwig commented 9 years ago

Ah, alright. 0.4 doesn't claim to support it (check setup.py) but I'll add that for the 0.4.1.

jayvdb commented 9 years ago

fwiw, this syntax added by @legoktm in cb875ae347f0b746d99159fa7edb235006145fbd

I cant see any PEP explaining why this syntax is now invalid in py3.5, but I can see why they might have killed it. It is ambiguous. Does the \ apply before or after the if.

The simplest fix is to use codecs.open instead of open, as codecs.open supports encoding in Python 2.