473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

winreg module, need help to understand why i'm getting exception

HI all, i found winreg module from http://www.rutherfurd.net/python/winreg/index.html
very useful and simple, instead _winreg.

But i have a problem with this module, in its iterable part.

look at the following code

key = Key(HKLM,r"SYSTEM\CurrentControlSet\Services\Tcpip \Enum")
for i in key.values:
print i.value

and that is the exception

Traceback (most recent call last):
File "D:\.Projects\python\temp.py", line 21, in <module>
for i in key.values:
File "C:\Python25\Lib\site-packages\winreg.py", line 451, in next
return self.values[self.index - 1]
File "C:\Python25\Lib\site-packages\winreg.py", line 289, in
__getitem__
name = _winreg.EnumValue(self.hkey, key)[0]
WindowsError: [Error 259] No more data is available
so there is some problem with iterate, i think
i am still a beginner, so i cant understand why this appears, and what
should i fix.

if anyone have some time to look closer to this module, i will
appreciate this very much.

thanks.

Jun 27 '08 #1
2 2185
On Apr 19, 6:20 am, hellt <Dodin.Ro...@gmail.comwrote:
HI all, i found winreg module fromhttp://www.rutherfurd.net/python/winreg/index.html
very useful and simple, instead _winreg.

But i have a problem with this module, in its iterable part.

look at the following code

key = Key(HKLM,r"SYSTEM\CurrentControlSet\Services\Tcpip \Enum")
for i in key.values:
print i.value

and that is the exception

Traceback (most recent call last):
File "D:\.Projects\python\temp.py", line 21, in <module>
for i in key.values:
File "C:\Python25\Lib\site-packages\winreg.py", line 451, in next
return self.values[self.index - 1]
File "C:\Python25\Lib\site-packages\winreg.py", line 289, in
__getitem__
name = _winreg.EnumValue(self.hkey, key)[0]
WindowsError: [Error 259] No more data is available

so there is some problem with iterate, i think
i am still a beginner, so i cant understand why this appears, and what
should i fix.

if anyone have some time to look closer to this module, i will
appreciate this very much.
The problem is not in your code, but in the module. The EnumValue()
and EnumKey() functions in the _winreg module raise WindowsError when
there are no more keys or values to retrieve. So, go inside the module
and modify that line to something like:

# There should be a for or a while loop around here
try:
name = _winreg.EnumValue(key, index)
except EnvironmentError:
Jun 27 '08 #2
Sorry, the above post is not complete. This is the rest:

# There should be a for or a while loop around here
try:
name = _winreg.EnumValue(key, index)
except EnvironmentError:
# It raises WindowsError, but the _winreg documentation
# recommends catching EnvironmentError
break
else:
# do something with 'name'
...

Anyway, I'd recommend using _winreg instead of the module you're
using, since it clearly has errors, and it's not on the standard
library.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James S | last post by:
Hi, Basically I've been fighting with this code for a few days now and can't seem to work around this problem. Included is the output, the program I use to get this error and the source code for...
17
by: Pam Ammond | last post by:
I need to use Microsoft Access Automation within a Visual Studio 2003 program written in C# for Windows Forms. When a button is clicked in my VS.NET program, I want it to run a Microsoft Access...
8
by: Floris van Haaster | last post by:
Hi All! I have a question, i have a web application and I store some member information in a variable i declared in a module like: Public some_info_variable as string in module1.vb But...
30
by: Franck PEREZ | last post by:
Hello, I'm developing a small XML marshaller and I'm facing an annoying issue. Here's some sample code: ########### My test application ############ class Foo(object): #The class I'd like to...
4
by: John please don't spam me! | last post by:
Hi Guys, I writing a project with just one module in it (the reason for this is to debug code before it becomes a service) and am getting an error which I do not understand: No accessible...
10
by: Tom Plunket | last post by:
I've got a bunch of code that runs under a bunch of unit tests. It'd be really handy if when testing I could supply replacement functionality to verify that the right things get called without...
6
by: usenet1 | last post by:
I'm a newbie with hopefully an easy question. I'm trying to write some "C" code that will run a python script that can in turn call some "C" functions. However I'm having a problem getting...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
22
by: ben mitch | last post by:
Hi I hope you'll see this cross-post (c/c++) as appropriate. I also admit immediately that the question *may* turn out to be compiler-/os-specific, in which case I apologize. But I wonder if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.