Package name with '.' in them: Python Bug ?

Yannick Patois patois at calvix.org
Fri Mar 19 13:12:03 EST 2004


Hi,


Terry Reedy wrote:
> "Yannick Patois" <patois at calvix.org> wrote in message
>>Under some naming conditions of module files, it seems that python lost
>>class static variables values.
> Since 'static variable' is not a Python concept, I do not know what you
> mean.

As you're so smart and you read the following, how do you call 'a' in 
class A ?
That's what I want to qualify.


>>The value 1 obtained as expected (A.a is a static value and keept as
> such).
> Given that you rebound A.a to 1 from None, I especially do not know what
> you mean.

I dont understand.


>>If now I just *rename* file B to B.1, without any change in the code
>>(except name='B' become name='B.1' in aTest.py), content of B.1.py file
>>being exacty the same as content of B.py, I get:
> 
> As you seem to be aware, Python expects modules to have a 'nice' name
> consisting of
> legal_Python_indentifier.py.

Which are ? Where to find this info ?

>  If you evade this, you are a bit on your own
> and may run into untested corner cases.

Untested area contains bugs, that's why it's interesting to test them.

>>$ ./aTest.py
>>None
>>Renaming B.py to B.1.py made A unable to keeps the value of it's static
>>variable.
> 
> It seems to me that it *kept* its original value.

However you called it, it doesnt behave the same (and doesnt behave the 
way python should work). The change is only a file name, no more.

> I would put more print
> statements into both A.A and B.B and maybe even aTest.py to see where
> execution first differs.

It breaks in B, if I remember well.

>>Any idea ? Is it well a bug ? Some feature I didnt understood ? I read
>>about submodule naminig using dots as separator, but I cant relate it
>>towhat I saw here.
>  
> import b.b1 would normally mean import file (module) b1 in the b package
> directory.

It's not the case here: would have it be that the import statement would 
have broke with "cant find that module".

>  But imp obviously did not find fine '1' in a 'B' directory.

It didnt seek for it, it just loaded 'B.1' as asked. Everything seems to 
work, except that some internal python dictionnary has likely been 
corrupted.

Correct behavior would either be "break on 'cant import module 1 from 
B'" or "correctly import B.1 without corrupting anything."

To me, that's look to be a bug.

	Yannick

-- 
_/ Yannick Patois \___________________________________________________
| web: http://feelingsurfer.net/garp/ | Garp sur irc undernet          |
| email:  patois at calvix.org           |                                |
| ATTAC dans le Pays de Gex: http://attacgex.ouvaton.org               |



More information about the Python-list mailing list