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

Python Version Compatibility Bugs #129

Closed
jptiilik opened this issue May 18, 2017 · 7 comments
Closed

Python Version Compatibility Bugs #129

jptiilik opened this issue May 18, 2017 · 7 comments
Labels

Comments

@jptiilik
Copy link

How did it happen?

  1. Open existing Sketch file (5 pages with artboard + Symbols page) on Sketch 44 (41411)
  2. Install the plugin
  3. Select: Plugins > Git > Advanced > Generate files for pretty diffs

Error log

Traceback (most recent call last):
  File "/Users/Petteri/Library/Application Support/com.bohemiancoding.sketch3/Plugins/Git 2.sketchplugin/getArtboardNames.py", line 15, in <module>
    name = pageName + "/" + artboardName
TypeError: can't concat bytes to str

@jptiilik
Copy link
Author

Caught a new one with a bit more info. Any idea what is going on?

Traceback (most recent call last):
  File "/Users/Petteri/Library/Application Support/com.bohemiancoding.sketch3/Plugins/Git 2.sketchplugin/getArtboardNames.py", line 5, in <module>
    obj = json.load(sys.stdin)
  File "/Users/Petteri/.pyenv/versions/3.4.3/lib/python3.4/json/__init__.py", line 265, in load
    return loads(fp.read(),
  File "/Users/Petteri/.pyenv/versions/3.4.3/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6642: ordinal not in range(128)

@mathieudutour
Copy link
Owner

hum not sure. Is there some "weird" characters in your pages/artboard names?

@jptiilik
Copy link
Author

Nothing weird, just ASCII characters from 97 to 122 (lowercase english). To be sure I renamed all the pages and artboards to get rid of possible invisible characters.

Maybe something to do with Python ASCII encoding? A quick Google search: TypeError: can't concat bytes to str gives multiple results, like http://stackoverflow.com/questions/606191/convert-bytes-to-a-python-string?rq=1

@mathieudutour
Copy link
Owner

Oh what version of python do you have? I think in python3, there is no implicit conversion anymore.

Hum can you try opening the file in question (plugins > manage plugins > the small cog > show plugins folder > right click Git.sketchplugin > show package contents > getArtboardNames.py) and change the line 15 to name = pageName.decode("utf-8") + "/" + artboardName.decode("utf-8")? Is it working?

@jptiilik
Copy link
Author

I have python 3.6.1 (latest). I tested it with 2.7.8 and it works nicely!

With 3.6.1, after modifying getArtboardNames.py, the error goes away, but there is a new one:

Traceback (most recent call last):
  File "/Users/Petteri/Library/Application Support/com.bohemiancoding.sketch3/Plugins/Git.sketchplugin/getArtboardNames.py", line 17, in <module>
    if len(ignore) == 0 or all(regex.match(name) == None for regex in ignore):
TypeError: object of type 'map' has no len()

This is explained here: http://stackoverflow.com/questions/21572840/map-object-has-no-len-in-python-3-3. I don't know python good enough to fix this myself.

@0xcaff 0xcaff added the bug label Dec 26, 2017
@0xcaff 0xcaff changed the title Unable to create files for pretty diffs Python Version Compatibility Bugs Dec 26, 2017
@kidGodzilla
Copy link

kidGodzilla commented Jun 27, 2018

I'm also experiencing this bug, latest Sketch, Python 3.6.4, no special characters (script is attempting to concat 'Page 1' and 'Artboard', but one of these is not a string). Going to dig into this more and see if I can build locally / debug.

@mathieudutour
Copy link
Owner

fixed in 0.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants