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 2010年02月19日 22:04 by swalker, last changed 2022年04月11日 14:56 by admin.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| shutil_copytree_doc.patch | lokare.ameya, 2011年05月19日 07:45 | review | ||
| Messages (8) | |||
|---|---|---|---|
| msg99597 - (view) | Author: Shawn (swalker) | Date: 2010年02月19日 22:04 | |
The error handling present in the implementation of shutil.copytree in python 2.6.4 (and perhaps other versions) is non-standard and partially broken. In particular, I'm unable to find any pydoc documentation that indicates that when copytree raises shutil.Error, that the error instead of the standard 2-tuple or 3-tuple was initialised with a list of entries. This means that callers catching EnvironmentError will be in for a surprise whenever they check e.args and find a tuple containing a list instead of just a tuple. Callers will also be disappointed to find that the entries in the list may be tuples or strings due to what looks like a bug in copystat error handling (it's using extend instead of append). I could possibly live with this behaviour somewhat if it was actually documented and consistent since shutil.Error can be caught specifically instead. It's also really unfortunate that the tuples that are stored here aren't the actual exception objects of the errors encountered so callers cannot perform more granular error handling (permissions exceptions, etc.). I'd like to request that this function: * be fixed to append copystat errors correctly * have shutil.Error documentation indicate the special args format and explain how it might be parsed * consider having it record the exception objects instead of the exception message * suggest that the default str() output for shutil.Error be improved |
|||
| msg103685 - (view) | Author: Tarek Ziadé (tarek) * (Python committer) | Date: 2010年04月20日 09:20 | |
I agree with all your points. The copystat error can be fixed right away and applied for 2.6 to 3.x For other points, I'll change the way the Error works but this will require an heavy deprecation process. In the meantime I can document the behavior, and provide some examples in the documentation (eg how to catch and manage the errors that were raised) |
|||
| msg136061 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2011年05月16日 02:38 | |
I also found the doc confusing. Does "This exception collects exceptions that raised during a multi-file operation." that Error is used for .rmtree or .move? If so, what format. If not, revise. And I also wondered how to access and use an Error. |
|||
| msg136268 - (view) | Author: Ameya Lokare (lokare.ameya) | Date: 2011年05月19日 07:45 | |
I've attached a proposed doc patch. I figured I'd move the Error argument format in the description of shutil.copytree, since the format is different for other functions (shutil.move, for example). |
|||
| msg138083 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年06月10日 15:37 | |
Thanks for the patch. Have you had a chance to investigate Terry’s question? |
|||
| msg138225 - (view) | Author: Ameya Lokare (lokare.ameya) | Date: 2011年06月13日 00:03 | |
shutil.Error is raised in copytree, copyfile and move, with a different format in each case. I was thinking the Error argument format could be documented in the descriptions of these functions (possibly with some examples). What do you think? |
|||
| msg138325 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年06月14日 15:11 | |
I think it would be good. |
|||
| msg138367 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年06月15日 13:40 | |
See also http://mail.python.org/pipermail/docs/2010-August/001207.html for a similar report. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:57 | admin | set | github: 52217 |
| 2011年06月15日 13:40:35 | eric.araujo | set | messages: + msg138367 |
| 2011年06月14日 15:11:50 | eric.araujo | set | assignee: tarek -> eric.araujo messages: + msg138325 versions: - Python 3.1 |
| 2011年06月13日 00:03:18 | lokare.ameya | set | messages: + msg138225 |
| 2011年06月10日 15:37:59 | eric.araujo | set | messages: + msg138083 |
| 2011年05月19日 07:45:59 | lokare.ameya | set | files:
+ shutil_copytree_doc.patch nosy: + lokare.ameya messages: + msg136268 keywords: + patch |
| 2011年05月16日 02:38:17 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg136061 versions: - Python 2.6 |
| 2010年05月16日 18:28:32 | eric.araujo | set | nosy:
+ eric.araujo |
| 2010年04月20日 09:20:59 | tarek | set | priority: normal assignee: tarek versions: + Python 3.1, Python 2.7, Python 3.2, Python 3.3 nosy: + tarek messages: + msg103685 resolution: accepted |
| 2010年02月19日 22:12:22 | dhduvall | set | nosy:
+ dhduvall |
| 2010年02月19日 22:04:16 | swalker | create | |