On Sun, May 08, 2011 at 01:18:56PM +0300, Elefterios Stamatogiannakis wrote:
> You are right, and at first i too thought that CPython's behavior wasn't > right. Nevertheless, maybe there is a reason that CPython behaves in > this non consistent way, and other programs may hit this too. > > As it is right now, i prefer pypy's implementation on this, as it makes > more sense, and it is easily corrected. I had a quick look at your code and i don't fully grasp why you didn't just use setattr which in my understanding is the correct way to go about this, touching anything starting with "__" or "_" should be avoided as you should not rely on those attributes, for example when passed in as an argument to a function/method. i understand that you are invoking it on a known object and not a passed argument but i would still apply the same rules and try to avoid relying on direct access to those attributes and instead call them in the proper manner i would have a hard time calling this a pypy bug, i would say the code is too closly coupled to the implemetnation of dict. > You are exactly right, and i've more or less used code like the one you > presented. My only problem is that i believe that pypy shouldn't have > answered at my first example (In [12]:...) above that cElementTree > exists in xml.etree .Or maybe it should short circuit cElementTree to > point at ElementTree. To declare that something exists, and then when > somebody tries to use it, to throw an exception, isn't that nice. looks like the lib is in the lib-python/2.7 and not lib-python/modified-2.7 directory and so it appears to be a side effect of importing the python std-lib as a side note cElementTree is gone in python 3.3 (didn't check the other versions) and most python libs with optional c versions now autodetect if the lib is installed and use that (eg Pickle and cPickle). using the try/except clause is the recommended idiom to avoid this situation when there are multiple versions of the same lib available i also would not call this a pypy bug as you rightly pointed out people may see pypy as a cpython replacment and perhaps noting the above 2 things in the cpython_diffrences.rst file in the doc folder would be a good idea hope i am right, feel free to flame me if i am not _______________________________________________ pypy-dev@codespeak.net http://codespeak.net/mailman/listinfo/pypy-dev