bedevere-app · GitHub

Test failures in test_logging seems unrelated. It should be re-run.

  1. Raising for Socket devices is correct. The code raises OSError right now. So raising a specific sub-exception, SpecialFileError is correct.

  2. Block devices raise OSError too. So, good here.

For Character Device. This is a legitimate program at the moment and it will stop functioning after this change.

import shutil
shutil.copyfile('noisy_error_log.log', '/dev/null')
shutil.copyfile('/dev/null', 'empty_file.txt')

However, this is not pythonic and correct way piping to character device /dev/null is using subprocess.DEVNULL which uses os.devnull

Empty file is created using open and close call. Or pathlib.Path.touch

It only "works" because '/dev/null' happens to return EOF immediately It's incidental, not designed. Similarly, using /dev/random would be boundless call and an exploit.

So, it okay to raise against the Character Device too.

I did a github search of using shutil with /dev/null and I couldn't find any.

Read the original on github.com ↗