Forums

OSError when modifying extended attributes (setxattr, getxattr)

When attempting to modify or read extended attributes, I receive the error OSError: [Errno 95] Operation not supported: 'filename'. This occurs when I use the os module in python 3.10.5, for example os.getxattr("filename", "xattr"). The same holds for os.setxattr.

Pretty new to pythonanywhere, so any help would be greatly appreciated.

Could you show a longer bit of your code? String "filename" does not look like a valid path, but rather like some example.

Sure. When running python3 on any of my other linux systems, I can run the following commands and am met with the expected behavior. Assume there is an arbitrary text file called test.txt in the working directory.

import os
os.setxattr("test.txt", "user.meta", b"metadata")
os.getxattr("test.txt", "user.meta")

The output of the last line is b"metadata" in this example, as one would expect.

However, this functionality doesn't seem to exist on pythonanywhere. If I execute the same code on pythonanywhere, I am met with the error "OSError: [Errno 95] Operation not supported: 'test.txt'" for both the setxattr and getxattr calls.

The filesystem we're using on PythonAnywhere is not supporting extended filesystem attributes, so that will not work.