zopefoundation / Zope

Zope is an open-source web application server.
https://zope.readthedocs.io
Other
357 stars 101 forks source link

Strange call of policy.validate in Traversable #926

Open gotcha opened 4 years ago

gotcha commented 4 years ago

While debugging, I came to the following line:

https://github.com/zopefoundation/Zope/blob/b507c39e221b31782151b2c5da2fcc0f1f8f668f/src/OFS/Traversable.py#L315

Which passes None to validate instead of the name variable that is used at line 301.

@dataflake @icemac Do you see a reason for not passing the actual nameto that validate call ?

All other calls in restrictedTraverse (except 1) do pass the available namevariable.

dataflake commented 4 years ago

If you look at the git blame you will notice that none of us ever touched this code and it's been that way forever. So no, I do not know.

If there is an actual problem it would be helpful if you described it.

gotcha commented 4 years ago

I actually went through git blame until first commit by hannosch which sounds like moving from elsewhere. I know none of you did touch it.

I think it is spurious that the name is not used in this particular case. And I am asking advice of people I consider wise. Think of this as code review while trying to make sense of code when debugging.

And sorry for the noise if you think this makes no sense.

icemac commented 4 years ago

I think this code was added in https://github.com/zopefoundation/Zope/commit/e10b7d6edbba516bd6ae9d6a1f1a9d1ce5535219 (_none has the value of None and was changed in a later commit to None.) – Looks like it was introduced in Zope 2.9.

I must admit that I do not understand what was the goal of that change.