[solved] Bug in file.py?

When I try to use this:

with open('client.cfg', 'w') as config:
    ...

I get an error when I execute the build:

AttribueError: file instance has no attribute '__exit__'

I think it’s a bug/missing feature. Could this exit method please be added in the next version of Panda3D?

If I’d manually adapt ‘file.py’ to add support for ‘exit’, would the build process still work as expected?

Oops, that is my oversight, my apologies. I’ll add it.

You can certainly add it yourself as well, though it wouldn’t work in a p3d file until the published version of Panda also had the fix.

David

Thanks for the quick reply!

Would it work if I’d create a standalone application from the p3d file, using pdeploy with the -s option?

Hmm. Maybe, but that sounds like trouble.

How about if you just copied stdpy/file.py into your own tree, fixed it appropriately, and then put the line “from file import open” at the beginning of this module?

David

I’ll do that. Thanks!