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 2008年05月16日 04:49 by brett.cannon, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| fix_userdict.diff | nedds, 2008年09月27日 16:27 | UserDict fixer and test suite | ||
| Messages (30) | |||
|---|---|---|---|
| msg66900 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年05月16日 04:49 | |
In Python 3.0, the UserDict module was removed and the UserDict class was moved to the collections module. That change-over needs to be backported to 2.6 so that the UserDict module can be deprecated. |
|||
| msg66904 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年05月16日 04:59 | |
This doesn't make any sense to me. The 2.6 code runs fine as-is. The 2-to-3 tool can handle switching from UserDict.UserDict to collections.UserDict. What's the issue? And why is this marked as a release blocker? |
|||
| msg67089 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年05月20日 04:18 | |
You only kept the UserDict class, right? Well, that means you need to deprecate DictMixin and any other classes in that module. |
|||
| msg67090 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年05月20日 04:19 | |
And it is a release blocker as we are trying to get all deprecations into b1. |
|||
| msg67100 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年05月20日 04:46 | |
The DictMixin class gets renamed to collections.MutableMapping. So, it is just another 2-to-3 converter job. |
|||
| msg67101 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年05月20日 05:01 | |
The that needs to be added to 2to3. |
|||
| msg67357 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年05月26日 00:24 | |
Raymond, can you tell me exactly where each module-level thing in UserDict went and if it was renamed or not? That way the fixer can get written. |
|||
| msg67361 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年05月26日 03:49 | |
UserDict.UserDict is gone. UserDict.IterableUserDict class is now collections.UserDict. UserDict.Mixin is now collections.MutableMapping. The new classes comform to the new dict API, so they fixer needs to also make same method adaptatations as for dicts (i.e. d.keys() --> list (d.keys() and d.has_key --> d.__contains__). |
|||
| msg67378 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年05月26日 17:34 | |
I don't know if 2to3 can handle the class renames. Up to this point we have only been handling module renames. Collin, how doable is this? |
|||
| msg68248 - (view) | Author: Collin Winter (collinwinter) * (Python committer) | Date: 2008年06月15日 20:02 | |
It's doable, but there's no existing support similar to what fix_imports provides. I won't have time to work on this for the foreseeable future, but if someone is interested in working on this, I'd add this challenge: implement this in a way that generalizes well and is better/easier than what fix_imports does. I never expected fix_imports's mechanism to be so heavily reused, and as a result it's ass-slow. |
|||
| msg69112 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年07月02日 19:50 | |
There is a possible patch in issue2046. |
|||
| msg71354 - (view) | Author: Nick Edds (nedds) | Date: 2008年08月18日 17:59 | |
What's the current status of this? If nobody is working on it, I would be willing to give it a shot. Can somebody just confirm that I have a correct understanding of the problem. UserDict.UserDict needs a deprecation warning, UserDict.IterableUserDict becomes collections.UserDict, and UserDict.Mixin becomes collections.MutableMapping. Then for keys(), items(), and values(), I want to replace something like d.keys() to list(d.keys()). One added question: based on what I gathered from PEP 3106, this last part is only needed in a situation such as a = d.keys(), but not a situation like for key in keys:, so because in the later case wrapping the call to keys() in list() would presumably be suboptimal, is this something I should try and avoid? I'm not sure exactly how it could be done, but I have some idea of how it to do it. |
|||
| msg71355 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年08月18日 18:07 | |
On Mon, Aug 18, 2008 at 10:59 AM, Nick Edds <report@bugs.python.org> wrote: > > Nick Edds <nedds@uchicago.edu> added the comment: > > What's the current status of this? I think it is waiting for someone to work on it. > If nobody is working on it, I would > be willing to give it a shot. Great! > Can somebody just confirm that I have a > correct understanding of the problem. > UserDict.UserDict needs a deprecation warning, UserDict.IterableUserDict > becomes collections.UserDict, and UserDict.Mixin becomes > collections.MutableMapping. In theory, yes, but the superclasses have changed, so I don't know if having a fixer is really the best option in this case since it is not a simple renaming. Perhaps deprecation warnings stating that the classes have been moved and given different superclasses would make more sense? > Then for keys(), items(), and values(), I > want to replace something like d.keys() to list(d.keys()). Sure, but how the heck are you going to get 2to3 to do this properly just for UserDict instances? Doesn't the keys()/values()/items() fixer already do this blindly anyway? > One added question: based on what I gathered from PEP 3106, this last > part is only needed in a situation such as a = d.keys(), but not a > situation like for key in keys:, so because in the later case wrapping > the call to keys() in list() would presumably be suboptimal, is this > something I should try and avoid? I'm not sure exactly how it could be > done, but I have some idea of how it to do it. > Yes, you are right that wrapping the call in a for loop is not needed since code will never come across it. But as I said above, doesn't the fixer for dicts already handle all of this? |
|||
| msg71378 - (view) | Author: Nick Edds (nedds) | Date: 2008年08月18日 21:08 | |
Ahh right. I totally forgot that there was already a fix_dict.py that took care of that. |
|||
| msg71650 - (view) | Author: Nick Edds (nedds) | Date: 2008年08月21日 15:24 | |
I've been thinking about this a bit, and I don't see how handling it should be all that different from handling module renaming. For import UserDict, we can just change UserDict to collections and deal with UserDict.UserDict with a deprecation warning and UserDict.IterableUserDict and UserDict.Mixin with transformations to collections.UserDict and collections.MutableMapping. For from imports, we can raise the deprecation warning on UserDict, and otherwise change from UserDict import ... to from collections import ... and then for non-import appearances of UserDict, IterableUserDict, and Mixin rename or raise a deprecation warning as appropriate. For the other import cases, similar things could be done. I think the old version of fix_imports, which had support like this, would basically be all that we need. I should be able to mimic that functionality, but also make it more scalable than the previous version. Is there something I'm missing here about the difference between modules and classes? From the use-cases I've observed of UserDict, it seems like this functionality would be sufficient. |
|||
| msg71667 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年08月21日 18:33 | |
As I said, it isn't using the import filter, it's whether this should be done through a warning instead because the superclasses have changed. I really should ask on python-dev about this. |
|||
| msg71669 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年08月21日 18:49 | |
You know what, Nick, go for the fixer. UserDict.UserDict will need a deprecation warning, but otherwise a fixer for IterableUserDict and DictMixin is fine. And I can handle the deprecation if you want. |
|||
| msg71891 - (view) | Author: Nick Edds (nedds) | Date: 2008年08月24日 22:00 | |
How soon is this needed by? I probably won't have a chance to do it in the next week, but it shouldn't take that long to make once I get a chance to work on it. |
|||
| msg71903 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年08月24日 23:41 | |
On Sun, Aug 24, 2008 at 3:00 PM, Nick Edds <report@bugs.python.org> wrote: > > Nick Edds <nedds@uchicago.edu> added the comment: > > How soon is this needed by? I probably won't have a chance to do it in > the next week, but it shouldn't take that long to make once I get a > chance to work on it. > rc1 is Sep. 3, with rc3 Sep 17 (at the moment). Hitting either should be okay, although obviously the sooner the better. |
|||
| msg72970 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2008年09月10日 15:58 | |
I still don't see why this is a release blocker. Adding a 2to3 fixer certainly isn't a release blocker - if the fixer isn't available, users would need to manually fix the code. Adding a Py3k warning shouldn't be a release blocker, either - I think such warnings could get added in 2.6.1 also (as they are only issued if you invoke Python with -3). Tentatively lowering the priority to normal. |
|||
| msg73347 - (view) | Author: Nick Edds (nedds) | Date: 2008年09月17日 22:10 | |
Sorry about the delay with this. I've finally found some time to work on this, so it should be completed within the next couple of days. |
|||
| msg73915 - (view) | Author: Nick Edds (nedds) | Date: 2008年09月27日 02:25 | |
I have the functionality for this working, and will post it tomorrow when I complete its test suite. |
|||
| msg73933 - (view) | Author: Nick Edds (nedds) | Date: 2008年09月27日 16:27 | |
Here is a fixer and test suite for the UserDict. It doesn't do a very good job handling imports with 'as' right now, but it's core functionality appears to be working. If I get a chance I will improve its handling of 'as' cases at some point in the future, but I think this is an alright start. It passes all tests. |
|||
| msg74107 - (view) | Author: Nick Edds (nedds) | Date: 2008年10月01日 02:09 | |
Could somebody else take a look at this and check in it if it looks alright? I think that it works currently but I can't check it in... |
|||
| msg74278 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年10月03日 22:21 | |
The patch looks very good over all. However, I'm not completely sure that 2to3 needs to give a warning on UserDict.UserDict instances. Wouldn't it be better to handle that with a py3k warning in UserDict? |
|||
| msg74279 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年10月03日 22:23 | |
Also, I believe the variable initializations at the beginning of the transform method are unneeded. |
|||
| msg102620 - (view) | Author: Jeroen Ruigrok van der Werven (asmodai) * (Python committer) | Date: 2010年04月08日 14:44 | |
What's the consensus on this? I ask since I actually ran into code today that uses DictMixin and as such wasn't converted by the 2to3 tool. |
|||
| msg102623 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2010年04月08日 15:36 | |
UserDict.DictMixin needs to convert to collections.MutableMapping |
|||
| msg102624 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2010年04月08日 15:53 | |
Converting DictMixin to collections.MutableMapping is not necessarily a complete solution. MutableMapping does not provide all the methods that DictMixin does. See for example the problems encountered in issue 7975. |
|||
| msg164532 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2012年07月02日 19:26 | |
Closing since 2.7 is already out the door. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:34 | admin | set | github: 47125 |
| 2012年07月02日 19:26:26 | brett.cannon | set | status: open -> closed resolution: wont fix messages: + msg164532 |
| 2010年11月29日 16:25:48 | eric.araujo | set | superseder: patch to fix_import: UserDict -> collections -> |
| 2010年11月29日 16:25:41 | eric.araujo | link | issue2046 superseder |
| 2010年11月29日 16:24:49 | eric.araujo | set | nosy:
+ eric.araujo |
| 2010年04月10日 22:10:25 | loewis | set | nosy:
loewis, brett.cannon, collinwinter, rhettinger, benjamin.peterson, asmodai, nedds, r.david.murray components: + 2to3 (2.x to 3.x conversion tool), - Library (Lib) |
| 2010年04月08日 15:53:17 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg102624 |
| 2010年04月08日 15:36:41 | rhettinger | set | messages: + msg102623 |
| 2010年04月08日 14:44:07 | asmodai | set | nosy:
+ asmodai messages: + msg102620 |
| 2008年10月03日 22:23:20 | benjamin.peterson | set | messages: + msg74279 |
| 2008年10月03日 22:21:05 | benjamin.peterson | set | messages: + msg74278 |
| 2008年10月01日 03:07:03 | benjamin.peterson | set | assignee: benjamin.peterson nosy: + benjamin.peterson |
| 2008年10月01日 02:09:54 | nedds | set | messages: + msg74107 |
| 2008年09月27日 16:27:30 | nedds | set | files:
+ fix_userdict.diff keywords: + patch messages: + msg73933 |
| 2008年09月27日 02:25:08 | nedds | set | messages: + msg73915 |
| 2008年09月17日 22:10:47 | nedds | set | messages: + msg73347 |
| 2008年09月10日 15:58:55 | loewis | set | priority: release blocker -> normal nosy: + loewis messages: + msg72970 |
| 2008年09月09日 13:13:03 | barry | set | priority: deferred blocker -> release blocker |
| 2008年09月04日 01:09:19 | benjamin.peterson | set | priority: release blocker -> deferred blocker |
| 2008年08月24日 23:41:08 | brett.cannon | set | messages: + msg71903 |
| 2008年08月24日 22:00:39 | nedds | set | messages: + msg71891 |
| 2008年08月21日 22:24:06 | benjamin.peterson | link | issue2012 superseder |
| 2008年08月21日 18:49:19 | brett.cannon | set | assignee: collinwinter -> (no value) messages: + msg71669 |
| 2008年08月21日 18:33:02 | brett.cannon | set | priority: high -> release blocker messages: + msg71667 |
| 2008年08月21日 15:24:58 | nedds | set | messages: + msg71650 |
| 2008年08月18日 21:08:01 | nedds | set | messages: + msg71378 |
| 2008年08月18日 18:07:32 | brett.cannon | set | messages: + msg71355 |
| 2008年08月18日 17:59:26 | nedds | set | nosy:
+ nedds messages: + msg71354 |
| 2008年07月02日 19:50:45 | brett.cannon | set | superseder: patch to fix_import: UserDict -> collections messages: + msg69112 |
| 2008年07月02日 19:50:24 | brett.cannon | unlink | issue2046 superseder |
| 2008年07月02日 19:49:43 | brett.cannon | link | issue2046 superseder |
| 2008年06月15日 20:02:49 | collinwinter | set | messages: + msg68248 |
| 2008年06月08日 23:28:19 | benjamin.peterson | unlink | issue2775 dependencies |
| 2008年06月08日 23:25:09 | benjamin.peterson | set | priority: release blocker -> high |
| 2008年05月26日 17:34:32 | brett.cannon | set | assignee: brett.cannon -> collinwinter messages: + msg67378 nosy: + collinwinter |
| 2008年05月26日 03:59:16 | rhettinger | set | assignee: rhettinger -> brett.cannon |
| 2008年05月26日 03:50:21 | rhettinger | set | messages: + msg67361 |
| 2008年05月26日 00:24:21 | brett.cannon | set | assignee: rhettinger messages: + msg67357 |
| 2008年05月20日 05:01:29 | brett.cannon | set | status: closed -> open messages: + msg67101 title: Backport UserDict move in 3.0 -> Write UserDict fixer for 2to3 |
| 2008年05月20日 04:46:10 | rhettinger | set | status: open -> closed messages: + msg67100 |
| 2008年05月20日 04:19:16 | brett.cannon | set | messages: + msg67090 |
| 2008年05月20日 04:18:50 | brett.cannon | set | messages: + msg67089 |
| 2008年05月16日 04:59:51 | rhettinger | set | nosy:
+ rhettinger messages: + msg66904 |
| 2008年05月16日 04:49:20 | brett.cannon | link | issue2775 dependencies |
| 2008年05月16日 04:49:07 | brett.cannon | create | |