Can’t save a document

Hi! I’m getting this message when trying to save a document:

The document “Test.glyphs” could not be saved. -[OC_PythonNumber _fastCStringContents:]: unrecognized selector sent to instance 0x60000de84720

I assume it has something to do with stored usedData (although I thought I was using allowed types), but not sure which one exactly causes the problem. Any way to know that? Thank you!

Can you show the script or send it to me?

I can, but it’s over 1000 lines and I really don’t want to take that much of your time to go through it :slight_smile:
I think I found where it happens, but don’t know how to solve:

This is key, value of a dictionary added to userData:
(<type 'int'>, <type 'dict'>)

And after the file is reopened it’s casted to:
(<type 'objc.pyobjc_unicode'>, <objective-c class __NSDictionaryM at 0x7fff883f48e0>)

And the issue seem to happen when the userData of a glyph contains two dicts in both of these types (when I add a new dict in addition to previously saved). Inside those dicts there are nested dicts with strings, numbers, booleans and None.

Could that cause it? Any solution other than re-writing all dicts every time or something like that?

Thank you!

Thank you, seems like that should be it!
One thing, how to save None? objcObject( None ) gives me:
global name 'NSNull' is not defined

I guess I can use zero, but it might be confusing

Just don’t save anything for the Null case?
Glyphs omits all default values when saving a file to save space and time.

1 Like

Can I ask, when I store a objcObject( int ) as a dictionary key it’s:
<class 'objc._pythonify.OC_PythonInt'>

But after reopening the document it’s casted to unicode:
<type 'objc.pyobjc_unicode'>

Is there a way to store it as a number?

I had a look at the original problem. It seems to be a bug in PyObjC but I could work around it. So no need for using objcObject() any more.

I even looked into supporting Null but that is not possible without breaking compatibility with the plist standard.

1 Like

Hi! I’m facing something weird with userData in Glyphs 2 (2.6.10 (1364)): it randomly swaps layer.userData[‘myKey’] to layer.userData[-2] and just as randomly becomes unable to save the document with this error:

The document “123.glyphs” could not be autosaved. -[OC_BuiltinPythonNumber length]: unrecognized selector sent to instance 0x7f7e867d3ed0

By randomly I mean I see no pattern — it works and doesn’t work with the same data. All I’m trying to do is to save a small dict with floats and strings (or even convert all floats to strings to avoid Nulls). Any chance you have an idea what might be causing it or how to save it properly?

There seems to be a plugin or script that sets the user data.