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