Granularity of OSError
Sean DiZazzo
half.italian at gmail.com
Fri Sep 18 21:48:33 EDT 2009
More information about the Python-list mailing list
Fri Sep 18 21:48:33 EDT 2009
- Previous message (by thread): Granularity of OSError
- Next message (by thread): Granularity of OSError
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sep 18, 5:23 pm, Christian Heimes <li... at cheimes.de> wrote: > kj wrote: > > For example, LBYL would look like this: > > > if os.path.isfile(some_file): > > os.unlink(some_file) > > > In contrast, EAFP would look like this: > > > try: > > os.unlink(some_file) > > except OSError: > > pass > > The two version aren't equal. The first one suffers from a race > condition which may lead to a severe security issue. The file may be > gone or replaced by a different file in the time span between the check > and the call to unlink(). > > Christian Thanks for pointing that out. I never thought of it before. ~Sean
- Previous message (by thread): Granularity of OSError
- Next message (by thread): Granularity of OSError
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list