I don't know. But trying to remove a directory using part of your code gives me:
For development purposes, it might be a good idea to include a catch-all "else" in your except block and print out errno and strerror. This is for finding out the correct error codes for different things:
errno = 21 # not 256
strerror = "Is a directory"
except OSError as (errno, strerror):
if errno == 21:
# What you want to say/do when trying to delete a directory.
elif errno == 2:
# What you want to say/do when deleting a non-existent file.
# So you can find out what error codes are being returned for
# for stuff you don't know about yet.
print errno, strerror