homepage

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.

classification
Title: Iterators over _winreg EnumKey and EnumValue results
Type: enhancement Stage: patch review
Components: Extension Modules, Windows Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: brian.curtin Nosy List: Claudiu.Popa, brian.curtin, stutzbach, tim.golden, zach.ware
Priority: normal Keywords: needs review, patch

Created on 2010年02月07日 21:31 by brian.curtin, last changed 2022年04月11日 14:56 by admin.

Files
File name Uploaded Description Edit
keyvalue_iterators.diff brian.curtin, 2010年02月07日 21:31 patch against trunk r78055 review
Messages (7)
msg99020 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010年02月07日 21:31
While EnumKey and EnumValue directly implement the underlying Windows calls of the same name, they don't feel very Pythonic. The user has to create their own loop and increment a counter to get all of the keys or values, stopping the loop when WindowsError is raised.
I created IterKey and IterValue, iterators over RegEnumKeyEx and RegEnumValueEx respectively. This mainly began as playing around with writing Python iterators in C, but has proven to work pretty nicely so I figured I'd put it out there.
Patch includes docs and tests. Comments/suggestions welcome and appreciated.
msg99049 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2010年02月08日 16:12
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
WindowsError: [Error 6] The handle is invalid
I suspect that .iterkeys / .itervalues would be more
acceptable spellings as those mirror the dict methods.
Whether the idea of extending _winreg beyond the absolute
basics will fly I'm not sure. I don't often use it, but
this would be useful if I did...
#
On 07/02/2010 21:31, Brian Curtin wrote:
>
> New submission from Brian Curtin<curtin@acm.org>:
>
> While EnumKey and EnumValue directly implement the underlying Windows calls of the same name, they don't feel very Pythonic. The user has to create their own loop and increment a counter to get all of the keys or values, stopping the loop when WindowsError is raised.
>
> I created IterKey and IterValue, iterators over RegEnumKeyEx and RegEnumValueEx respectively. This mainly began as playing around with writing Python iterators in C, but has proven to work pretty nicely so I figured I'd put it out there.
>
> Patch includes docs and tests. Comments/suggestions welcome and appreciated.
>
> ----------
> components: Library (Lib), Windows
> files: keyvalue_iterators.diff
> keywords: needs review, patch, patch
> messages: 99020
> nosy: brian.curtin
> priority: normal
> severity: normal
> stage: patch review
> status: open
> title: Iterators over _winreg EnumKey and EnumValue results
> type: feature request
> versions: Python 2.7, Python 3.2
> Added file: http://bugs.python.org/file16170/keyvalue_iterators.diff
>
> _______________________________________
> Python tracker<report@bugs.python.org>
> <http://bugs.python.org/issue7877>
> _______________________________________
> _______________________________________________
> Python-bugs-list mailing list
> Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/mail%40timgolden.me.uk 
msg99050 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2010年02月08日 16:16
Sorry; the email interface messed that up. The code
which triggered the error was:
import _winreg
list (
 _winreg.IterValue (
 _winreg.OpenKey (_winreg.HKEY_CURRENT_USER, "Console")
 )
)
msg99053 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010年02月08日 16:35
Interesting, I'll take a look and see why that's happening.
Good point about the names.
msg111839 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010年07月28日 20:30
@Brian: @Tim: just a gentle nudge in the ribs in case this has slipped under the radar.
msg115290 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2010年09月01日 12:22
As most of the code in this patch was copied from EnumValue and EnumKey, it includes bugs from those functions that have since been fixed. I'm thinking of Issue #2810, although there might have been other changes.
Instead of duplicating code, it would be better to abstract out some of the common elements so that in the future changes only need to be made in one place.
While winreg isn't very Pythonic, I imagine most users write a simple wrapper around the functions to give it a more Pythonic feel. I have been using a home-brewed class that implements the MutableMapping ABC. I just posted it as a recipe on ActiveState:
http://code.activestate.com/recipes/577381-collectionsmutablemapping-wrapper-around-_winreg/ 
msg222708 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014年07月10日 22:23
@Zach any interest in this?
History
Date User Action Args
2022年04月11日 14:56:57adminsetgithub: 52125
2019年03月15日 22:28:35BreamoreBoysetnosy: - BreamoreBoy
2015年03月08日 07:39:43Claudiu.Popasetnosy: + Claudiu.Popa
2014年07月10日 22:23:57BreamoreBoysetnosy: + BreamoreBoy, zach.ware

messages: + msg222708
versions: + Python 3.5, - Python 3.3
2011年02月15日 16:22:08brian.curtinsetnosy: - BreamoreBoy

versions: + Python 3.3, - Python 3.2
2010年09月01日 12:22:59stutzbachsetkeywords: patch, patch, needs review
nosy: + stutzbach
messages: + msg115290

2010年08月29日 23:03:05brian.curtinsetkeywords: patch, patch, needs review
assignee: brian.curtin
components: + Extension Modules, - Library (Lib)
versions: - Python 2.7
2010年07月28日 20:30:32BreamoreBoysetkeywords: patch, patch, needs review
nosy: + BreamoreBoy
messages: + msg111839

2010年02月08日 16:35:26brian.curtinsetkeywords: patch, patch, needs review

messages: + msg99053
2010年02月08日 16:16:45tim.goldensetmessages: + msg99050
2010年02月08日 16:12:29tim.goldensetnosy: + tim.golden
messages: + msg99049
2010年02月07日 21:31:39brian.curtincreate

AltStyle によって変換されたページ (->オリジナル) /