Skip to content
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

Fix for python syntax error in testStructure.py #21

Merged
merged 1 commit into from Nov 25, 2016
Merged

Fix for python syntax error in testStructure.py #21

merged 1 commit into from Nov 25, 2016

Conversation

idcrook
Copy link
Contributor

@idcrook idcrook commented Nov 25, 2016

  • since the file has non-ASCII characters, it can fail with a compile
    error if the doc type is not specified. This edit corrects for that.

Platform: macOS 10.12, Python 2.7.12

Error example

$ python ../SwiftPlate/testStructure.py test

File "testStructure.py", line 30
SyntaxError: Non-ASCII character '\xe2' in file testStructure.py on line 30, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

 - since the file has non-ASCII characters, it can fail with a compile
   error if the doc type is not specified. This edit corrects for that.

`$ python ../SwiftPlate/testStructure.py test`

	File "testStructure.py", line 30
	SyntaxError: Non-ASCII character '\xe2' in file testStructure.py on line 30, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
@codeOfRobin
Copy link
Contributor

codeOfRobin commented Nov 25, 2016

@uh, it's built in python3 @idcrook . And the invalid characters are ⭐️ emojis 😅

@idcrook
Copy link
Contributor Author

idcrook commented Nov 25, 2016

after putting the encoding declaration in the file (which is what this PR does), it successfully ran on my system (on Python 2.7.12)

# -*- coding: utf-8 -*-

Are you saying this PR should be rejected?

@codeOfRobin
Copy link
Contributor

codeOfRobin commented Nov 25, 2016

No, no. I just realised why it happened. Python 3 assumes UTF-8 encoding.

I have a tiny doubt though. Doesn't Python 2 have a different print syntax? I'd suggest you test it out by running swiftplate once (pass in whatever params you like), then run testStructure.py {{project_name_you_chose_previously}}, and see if it works.

Just tested, it worked!

@JohnSundell
Copy link
Owner

Great, so now we can run the tests on systems with both Python 2 and 3 🎉 Thanks for this @idcrook!

@JohnSundell JohnSundell merged commit 78bfc7a into JohnSundell:master Nov 25, 2016
@idcrook idcrook deleted the python-syntax branch November 25, 2016 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants