[PATCH] windows: import the pure version of osutil correctly

Matt Mackall mpm at selenic.com
Wed May 13 09:47:30 CDT 2009


On Wed, May 13, 2009 at 03:42:02PM +0200, Sune Foldager wrote:
> # HG changeset patch
> # User Sune Foldager <cryo at cyanite.org>
> # Date 1242221816 -7200
> # Node ID 718c71256f437b829eb1ee2cf9a19388696032dd
> # Parent  94e91205d9b6f7272d6a1b61c39de4c2555df240
> windows: import the pure version of osutil correctly
> 
> The pure version of osutil doen't have a posixfile attribute.
> This trips up demandimport, which assumes it's a submodule. When
> it tries to load it, it ends up loading the global posixfile
> module instead. The original osutil.posixfile is a function.

Seems like we should instead change the pure osutil.py to continue to
parallel osutil.c, so that nothing else needs to be aware that two
versions exist.

Alternately, we can change this to not use a from-style import, which
annoys the demandimporter anyway. The clean style is:

import osutil # at the top, demandimport won't load unless needed

...

try:
  posixfile = osutil.posixfile # do we have the fancy version?
except AttributeError:
  posixfile = sadposixfile
-- 
Mathematics is the supreme nostalgia of our time.


More information about the Mercurial-devel mailing list