Errors in ConfigParser python 2.5.1 module
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python2.5 (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
There are serious bugs in python 2.5.1 module ConfigParser.
file: wget -q http://
Script example:
#------
#!/usr/bin/env python
#coding=utf8
import os
import ConfigParser
import sys
import string
cfg = ConfigParser.
def isMobileDevice (sectionName):
map = dict (cfg.items(
if 'ismobiledevice' in map:
return map['ismobilede
elif 'parent' in map:
print cfg.items (sectionName)
return isMobileDevice (map['parent'])
else:
return False
def convertMask (mask):
mask = string.replace (mask, '\\', '\\\\')
mask = string.replace (mask, '.', '\\.')
mask = string.replace (mask, '?', '.')
mask = string.replace (mask, '*', '.*')
for taboo in '[]{}()^$':
mask = string.replace (mask, taboo, '\\' + taboo)
return mask
try:
descriptor = os.popen ('wget -q http://
cfg.readfp (descriptor)
except ConfigParser.Error:
print 'Cannot get browscap.ini'
sys.exit (-1)
mobileDeviceList = []
for section in cfg.sections():
print section
if isMobileDevice (section):
mobileDeviceL
if len (sys.argv) > 1:
descriptor = open (sys.argv[1], 'w')
else:
descriptor = sys.stdout
descriptor.
#------
And after execution got:
Traceback (most recent call last):
File "./mobile_
if isMobileDevice (section):
File "./mobile_
return isMobileDevice (map['parent'])
File "./mobile_
map = dict (cfg.items(
File "/usr/lib/
raise NoSectionError(
ConfigParser.
It was true, the ini file didn't have "Seamonkey 1.1" section. The ini file had a following structure:
ini file = list of named structures (sections)
each named structure (section) = list of pairs (name, value)
And some sections might have a reference to another (their parent) section by item ('parent', <another section name>)
But no pair has "Seamonkey 1.1" value.
Althoug, some sections has the following order of pairs:
Parent=SeaMonkey
Version=1.1
I suppose, the parser passed "\nVersion=".
Actually, there wasn't "Seamonkey" word in the whole ini file, there was only SeaMonkey.
Changed in python2.5: | |
status: | Fix Released → Invalid |
I think it' s not a ConfigParser error, because I've this traceback:
Traceback (most recent call last): sectionName) ) python2. 5/ConfigParser. py", line 544, in items section) NoSectionError: No section: 'Motorola Internet Browser'
File "conf.py", line 37, in <module>
if isMobileDevice (section):
File "conf.py", line 14, in isMobileDevice
return isMobileDevice (map['parent'])
File "conf.py", line 9, in isMobileDevice
map = dict (cfg.items(
File "/usr/lib/
raise NoSectionError(
ConfigParser.
The error should be given by the file structure (i think)
Bye