This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2013年02月01日 13:44 by brett.cannon, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg181079 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2013年02月01日 13:44 | |
If __loader__ is None then ValueError is raised, but if it is not defined then AttributeError is raised instead. Probably should harmonize around ValueError even in the missing attribute case since __loader__ = None is equivalent to the attribute not existing. I'm on the fence about considering this a bug, though, since the docs say if __loader__ == None then ValueError but does not directly mention what happens if the attribute is missing. Since anyone who has written code for this probably is catching both attributes (if at all since all but three modules coming from Python will have __loader__ defined ATM), it should be fine, but it is still a change in API/semantics that doesn't contradict the docs. |
|||
| msg181084 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2013年02月01日 16:24 | |
Should mention that this is probably no harder than changing a key getattr() call to None (as pointed out by Nick). |
|||
| msg181356 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2013年02月04日 17:49 | |
My vote is for making this a ValueError in both cases (and amending the doc appropriately as well). The error amounts to the same thing: the module did not have loader (implicitly or explicitly). If someone wants to distinguish between the two they can explicitly check __loader__ on the module. Incidently, _find_and_load_unlocked() has similar code to find_loader() (Lib/importlib/_bootstrap:1523) and raises ImportError instead of ValueError. That's actually fine since it's a different situation. However, _find_module() does not handle when __loader__ does not exist, so you would get neither ValueError nor ImportError. I expect we'd want it or _find_and_load_unlocked() to convert the AttributeError into ImportError to be consistent both with the fix for this issue and with how we handle the __loader__ == None case there. --- For reference, here is the original python-dev thread: http://mail.python.org/pipermail/python-dev/2013-January/123777.html The reference to ValueError is in the importlib docs: http://docs.python.org/dev/library/importlib.html#importlib.find_loader |
|||
| msg184097 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2013年03月13日 18:09 | |
New changeset cee04627bdd0 by Brett Cannon in branch 'default': Issue #17099: Have importlib.find_loader() raise ValueError when http://hg.python.org/cpython/rev/cee04627bdd0 |
|||
| msg184098 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2013年03月13日 18:11 | |
I decided not to backport since it shifts what exception is raised. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:41 | admin | set | github: 61301 |
| 2013年03月13日 18:11:19 | brett.cannon | set | status: open -> closed resolution: fixed messages: + msg184098 |
| 2013年03月13日 18:09:57 | python-dev | set | nosy:
+ python-dev messages: + msg184097 |
| 2013年02月23日 17:27:55 | gkcn | set | nosy:
+ gkcn |
| 2013年02月19日 14:42:49 | Ankur.Ankan | set | nosy:
+ Ankur.Ankan |
| 2013年02月04日 17:49:58 | eric.snow | set | messages: + msg181356 |
| 2013年02月03日 16:50:00 | brett.cannon | set | assignee: brett.cannon |
| 2013年02月03日 16:48:10 | brett.cannon | link | issue17115 dependencies |
| 2013年02月01日 19:15:51 | eric.snow | set | nosy:
+ eric.snow |
| 2013年02月01日 16:24:35 | brett.cannon | set | keywords: + easy |
| 2013年02月01日 16:24:30 | brett.cannon | set | messages: + msg181084 |
| 2013年02月01日 15:17:22 | barry | set | nosy:
+ barry |
| 2013年02月01日 14:07:23 | asvetlov | set | nosy:
+ asvetlov |
| 2013年02月01日 13:44:37 | brett.cannon | create | |