1.6 home straight
John Arbash Meinel
john at arbash-meinel.com
Wed Aug 13 15:42:12 BST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Adrian Wilkins wrote:
> Martin Pool wrote
>
>> * I believe there is a Windows-specific fix (?) which does not have
> 1.6 in the subject but wants to be merged across.
>
> I think this is referring to
>
> http://bundlebuggy.aaronbentley.com/project/bzr/request/%3C489ACEB7.1010503%40gmail.com%3E
>
> Introduced by
> revid:robertc at robertcollins.net-20080730095022-4tc7ij34c0tmejb5
>
>
>
> John Arbash Meinel wrote:
>> I think this is actually the wrong fix. There are comments and codepaths in the
>> osutils.py code that make it clear "walkdirs(file)" should not be an error.
>
>> try:
> names = sorted(_listdir(top))
> except OSError, e:
> if getattr(e, 'errno', None) == errno.ENOTDIR:
> # We have been asked to examine a file, this is fine.
> pass
> else:
> raise
>
>
> On the subject of this piece of code ; I would expect it to be far more costly
> to deal with an exception than it is to check that `file` is a directory in the
> first place. Am I just thinking with Java/C# coloured synapses?
It *is* slightly more expensive to catch an exception. But the common
case is that it is a directory, so it is actually *more* expensive in
the common case to check. Because doing "os.path.isdir()" is actually a
stat (aka system call) while doing try/except costs almost nothing
unless the exception is raised, and when it is raised, it is user-side,
not a system call.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkii8sQACgkQJdeBCYSNAANF5QCeNsdGQGVXG6fRSvSuVJViMU7Y
9M4AoLIjm/b3JpUXW/829OKxd+E8yfKN
=nRZK
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list