-
Notifications
You must be signed in to change notification settings - Fork 818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yaml2mml not compatible with python 3.5 #2447
Comments
Also has the same error on Debian with 3.5. We could make it a Python 2 script, but I'm open to suggestions which make it work on both while keeping output the same on Linux and Windows. |
The problem mostly arises from the fact that the file is opened as binary. Is there a reason for this? In theory a text file should be enough, as json should be text. Removing the 'b' from line 26 makes it work for both py2 and py3. |
The reason for binary was #2153 |
Yes, we need 'b' or it doesn't work on py2, giving different output depending on newline settings. |
I understand we want only \n on every platform as newline? I found no compatible way with JSON.dump() but using JSON.dumps() and encode to byte array seem to do the trick:
With python2 both methods yield files with same sha256sum. Tested only on Linux, I have no Windows system at hand. The python3 output has different sha256sum after every execution, the properties seem to have random sorting. Python3 output would need testing (I only have Kosmtik, does is process mml?) The python2 output on the other hand is stable. Should I prepare a pull request? |
That would be not so practical when working with git, maybe we can explicitly add a sort? |
Yes, adding sort_keys=True does produce the same and stable output for python 2/3.
|
Is the Windows output the same? |
Just for the record: Microsoft publishes virtual machines for testing Internet Explorer/Edge in different versions, but they are in fact just plain generic Windows machines, that you could use for anything. The only drawback is that the license is expiring every 90 days, so one has to roll back to the snapshot once in a while. It's even easy to remember the basic URL: modern.ie. |
The real answer to the original problem would have been to use |
This would probably not work for project.mml because it is marked as binary file (34ef136). You lose autocrlf but gain: "nor will it try to compute or print a diff for changes in this file when you run git show or git diff on your project." |
We can change this if needed |
#2459 has been refined and now been tested with Linux and Windows. Python 2&3 on Linux and Windows are producing same output (with LF newline). Only exception is redirecting output of --check parameter to file, but this is not what this switch is for. |
Made irrelevant by #2473. |
On my Arch Linux with python 3.5 yaml2mml.py fails. Probably because of #2225.
Steps to reproduce:
> python --version
Python 3.5.2
> pacman -Qi python-yaml
Version : 3.12-1
> git clone https://github.com/gravitystorm/openstreetmap-carto.git
> ./scripts/yaml2mml.py
[Error above]
Python 2 works fine
> python2 --version
Python 2.7.12
> pacman -Qi python2-yaml
Version : 3.12-1
> python2 ./scripts/yaml2mml.py
[No error]
The text was updated successfully, but these errors were encountered: