[issue2588] A bug in demandimport raises an AttributeError for modules which have already been imported

Anthony Lalande bugs at mercurial.selenic.com
Tue Jan 11 21:52:33 UTC 2011


New submission from Anthony Lalande <anthony.lalande at gmail.com>:

It seems that there is a divergence between the way demandimport populates 
module namespaces, and the way the native __import__ function does.

In short, it is possible to have something like:

  import package.foo

and, when one tries to access package.foo later *in the same source file*, get 
an error:

  AttributeError: 'module' object has no attribute 'foo'



I've put together a very simple test case, which demonstrates the problem. It 
is packaged in the form of a Mercurial extension which doesn't implement any 
commands. To replicate:

  hg --config "extensions.ditest=/path/to/demandimport_test"



I've derived two workarounds (documented within the sample code), but without 
getting buried in how CPython implements the __import__ call at a very low 
level, I'm not yet sure how to fix...?

Any help would be greatly appreciated!

----------
files: demandimport_test.tgz
messages: 14879
nosy: tonyboy
priority: bug
status: unread
title: A bug in demandimport raises an AttributeError for modules which have already been imported

____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue2588>
____________________________________________________
-------------- next part --------------
‹ Ð,M í™ÝjãFÇÕB)ÕMïÚÛ“„Å	¤Š>­­K/MÈ–BãÒ…¶YÛ³¶5f4Š×ïÒ7èËô²Ó3²”8Ú8 (Yr~¬‘2šÍœsþGg¥„Í£4áó…j X¦ŽŒÆ±m;(ŽÝnq´]},Ç	ÏñÃ0ôÁv/ì4¿”Û䙊$.å8U‘®jûa·Ñè#ó”û¸<~"$·üo
žr5X‹zs<„ûüï^åÿÀõ\ô:®v#w¿‡îã‹o¾4>7ŒŸ£~9‡wP¢ÛŒ¯ðçâO[EÿýÐ?y×ÿø”Çýþ¯Æ¿ÿ刿ñ÷õ.Ÿ]µ‹¹-3fõÙu’Æ"áé/þÖ?ýîõŽç»Nøýk¿É]%·õß´úïÕ¿ë:þMýû¡Oúoƒ½£<“GCž±ô+mÓìt:çóhgc at Y²4ã"% #F¤™’‘bM0lP¿¨WXr5ÍpÒ“˜æHŠ9Ì™Œs‰³Y› <֍s‘˜fÙÏ“\ñÙåŸB2K¤ìp}¦–¢:›HÆLsðßïBN#)ò4=§‡
EÁLDÉþÁí.®î’p¹¯»•×÷c•G³Ùêðê
Dq̲Œeå|ƒ„Ç(CXNx<ž^ˆ)ËpðÆ>°×˜©H)¹ÙT.ÓjÀµÕYzø¹ ÉÖ7窓š £9ƒ(»¾7ˆ†âm1̼Án"O”žáM'…ੁ—Ô„g0rŽ=YåÃÞS¶P§ÓT,Ñi³,qf<ÓÃËèûó1Wãr´o¯Œ,¤·3_Á"šFÇFfYVaFd!õ"vÏ•1‚ŽÜ)ý­—ƒËbÅì:¢Jg[åq0ÊÓmbY»ÕDªþjÁzð*Û…W ð¼ôšÉGÀ3Žñ¥ñºñpÃ=S?Ì.g9χؚÏÐüx_mûjε7’HEx­o«ÃêTÈp¹ÔM¯]<ªñ<˜wïì^ûD#Ådæ¹¼þ—Õ嫐/wi*¹ZÛ©’Ù¦ÑÞ
1Í`Ƨ£²ˆ–lz»&ûëX:Æ­rŒDv"¥½Ú¡ÐC‰ŸâèýÝ«nÅ™ŒxÆ̧΅/‘»êÿ*àš* ðyØõý­ê+ ýüï:ôüo‡Ç«ÿCƒêÿgÏmý7­þ-ôowoêßÒÔÔÿEÕ^ÕÚU~:‹äØ46‚ëµÈµ§þÃR&Û¨™î®_v6k€§¶ÂËåý£×›}	¼ýûß O=Ô׳zÿÛ5þoô%Ð}ù¿ò?º=ùßµ}»Kù¿
jüo
F"—
Õ xÿï8aá; ç;<^ýÿ£Aõÿ³§Fÿ
ªÿAß×úÇÿÿ»”ÿ[¡6ÿ‹”5øýwÛ÷?Žc…ÿzÿӏ—ÿ
ÊÿÏžý7¨þíëÿ
ýû.Õ­P›ÿ‹/«ÍÄÀCò¿çõ¿k{äÿVx¼üÿÖ üÿì©ÑƒêXþ/ôï„!ÕíPŸÿ—â)êÛëþ·Cò+<^þ?3(ÿ?{êòsêß"ÿ{Ý›ú÷C‡ôßñ,ʲõ—Ý}1|ÏbU}ÍÅvú.KAAAAAAñÉð?ÆÏ P  


More information about the Mercurial-devel mailing list