Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does python's `os.system` ever throw an exception?

Might the esteemed os.system of Python fame throw an exception? If so, which ones?

like image 590
Claudiu Avatar asked Mar 09 '11 20:03

Claudiu


1 Answers

os.system throws a TypeError if there is not exactly one string argument. If the fork fails due to resource or ulimit restrictions, it will return -1. If the argument is not valid in some way (like non-existing command), it will return a high error code. Apart from the aforementioned TypeError, os.system does not throw any exceptions.

like image 88
phihag Avatar answered Sep 28 '22 06:09

phihag