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: ConfigParser.getint failure on 2.3.3
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, zgoda
Priority: normal Keywords:

Created on 2003-12-21 18:37 by zgoda, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cp-getint-bug.py zgoda, 2004-05-18 11:47 Bug or not bug?
Messages (3)
msg19452 - (view) Author: Jarek Zgoda (zgoda) Date: 2003-12-21 18:37
It fails with this traceback:
jarek:~/projekty/jpawrk/trunk$ ./jpa.py
Traceback (most recent call last):
  File
"/home/jarek/projekty/jpawrk/trunk/lib/jt_mainwindow.py",
line 328, in OnMessageEdit
    self.cfg)
  File
"/home/jarek/projekty/jpawrk/trunk/lib/jt_msgeditwindow.py",
line 35, in editMessage
    dlg = MsgEditDlg(tmp, config)
  File
"/home/jarek/projekty/jpawrk/trunk/lib/jt_msgeditwindow.py",
line 69, in __init__
    self.__setProperties(config)
  File
"/home/jarek/projekty/jpawrk/trunk/lib/jt_msgeditwindow.py",
line 76, in __setProperties
    winSize = cfg.getWindowSize('msgedit')
  File
"/home/jarek/projekty/jpawrk/trunk/lib/jt_cfg.py", line
66, in getWindowSize
    return (self.cp.getint(windowName, 'width'),
  File "/usr/lib/python2.3/ConfigParser.py", line 315,
in getint
    return self._get(section, int, option)
  File "/usr/lib/python2.3/ConfigParser.py", line 312,
in _get
    return conv(self.get(section, option))
  File "/usr/lib/python2.3/ConfigParser.py", line 518,
in get
    return self._interpolate(section, option, value, d)
  File "/usr/lib/python2.3/ConfigParser.py", line 557,
in _interpolate
    if value.find("%(") != -1:
AttributeError: 'int' object has no attribute 'find'

The offending line in ConfigParser.py is line 553 which
reads:
value = rawval
In case of non-string values this will fail later,
since find() is a string method. Changing this line to:
value = str(rawval)
helps in case of numeric values (didn't check with
booleans, though).
msg19453 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2004-05-18 03:42
Logged In: YES 
user_id=3066

Are you passing non-string values to the .set() method?  The
_interpolate() method is called before ConfigParser even
performs data conversion, so it should only see strings.

The script being run in the traceback you show was not
attached, so I can't be sure how you're using ConfigParser.

The documentation for the .set() method has been found
lacking; this has been fixed in response to another bug
report.  Starting with Python 2.4, passing a non-string as
the value to the .set() method will cause a TypeError to be
raised.

If you were *not* passing a non-integer as the value
argument of the .set() method, please respond to this bug
report; a short script that demonstrates the problem would
help us diagnose the problem more carefully.
msg19454 - (view) Author: Jarek Zgoda (zgoda) Date: 2004-05-18 11:47
Logged In: YES 
user_id=92222

Thanks for clarification. And yes, the value passed to
.set() is of integer type, as may be found in attached script.
I am closing this report with resolution "Fixed".
History
Date User Action Args
2022-04-11 14:56:01adminsetgithub: 39723
2003-12-21 18:37:33zgodacreate