Comment 1 for bug 430645

Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 430645] [NEW] Warning on Windows

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John A Meinel wrote:
> Public bug reported:
>
> I don't know for sure why we are getting this, but on Windows I'm now
> seeing:
> $ bzr st
> C:\Users\jameinel\dev\bzr\bzr.dev\bzrlib\osutils.py:928: UserWarning:
> bzr: warning: Failed to load compiled extensions:
> No module named _readdir_pyx
> Bazaar can run, but performance may be reduced.
> Check Bazaar is correctly installed or set ignore_missing_extensions
> % '\n '.join(_extension_load_failures,))
>
>
> The main thing is that it is *expected* that we won't build _readdir_pyx
> on Windows, so we certainly shouldn't be warning that we are failing to
> load it. Arguably we shouldn't be trying to import it in the first place.
>
> affects bzr
> status confirmed
> importance critical
> assignee jameinel
>
> (only in bzr.dev, but we certainly wouldn't want to release 2.1.0b1 with
> this bug :)
>
> John
> =:->

This appears to be caused by this function:
def file_kind_from_stat_mode_thunk(mode):
   global file_kind_from_stat_mode
   if file_kind_from_stat_mode is file_kind_from_stat_mode_thunk:
       try:
           from bzrlib._readdir_pyx import UTF8DirReader
           file_kind_from_stat_mode = UTF8DirReader().kind_from_mode
       except ImportError, e:
           failed_to_load_extension(e)
           from bzrlib._readdir_py import (
               _kind_from_mode as file_kind_from_stat_mode
               )
   return file_kind_from_stat_mode(mode)
file_kind_from_stat_mode = file_kind_from_stat_mode_thunk

^- note that it is using a bound member function which is a bit strange.
But also that it always uses the _readdir_pyx version.

I doubt this function is terribly performance critical, so I don't think
missing the lib will require a warning, versus earlier when we make use
of the UTF8DirReader code.

So I propose:

=== modified file 'bzrlib/osutils.py'
- --- bzrlib/osutils.py 2009-09-11 06:39:56 +0000
+++ bzrlib/osutils.py 2009-09-16 11:20:53 +0000
@@ -1828,7 +1828,8 @@
             from bzrlib._readdir_pyx import UTF8DirReader
             file_kind_from_stat_mode = UTF8DirReader().kind_from_mode
         except ImportError, e:
- - failed_to_load_extension(e)
+ # This is one time where we won't warn that an extension
failed to
+ # load. The extension is never available on Windows anyway.
             from bzrlib._readdir_py import (
                 _kind_from_mode as file_kind_from_stat_mode
                 )

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqwyh0ACgkQJdeBCYSNAAM+3wCglnUJVJk0lg+cMSnWuOBWKmVy
rsgAoKA6EPT1rU/kir9y5ZhM0rqmYb1q
=qCLQ
-----END PGP SIGNATURE-----