Bug 551932 - python wrong exception handler
Summary: python wrong exception handler
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: livecd-tools
Version: 12
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Bruno Wolff III
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 575564 (view as bug list)
Depends On: 618002 618003
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-01-03 06:22 UTC by Alexey Kuznetsov
Modified: 2010-09-11 17:51 UTC (History)
9 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2010-09-11 17:51:54 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Alexey Kuznetsov 2010-01-03 06:22:35 UTC
[axet@axet-laptop livecd]$ rpm -qf /usr/lib/python2.6/site-packages/imgcreate/kickstart.py
python-imgcreate-031-1.fc12.1.x86_64


[axet@axet-laptop livecd]$ ./livecd.sh 
rm: cannot remove `*.iso': No such file or directory
Traceback (most recent call last):
  File "/usr/bin/livecd-creator", line 140, in <module>
    sys.exit(main())
  File "/usr/bin/livecd-creator", line 112, in main
    ks = imgcreate.read_kickstart(options.kscfg)
  File "/usr/lib/python2.6/site-packages/imgcreate/kickstart.py", line 56, in read_kickstart
    except IOError, (err, msg):
ValueError: need more than 1 value to unpack


<<<after patch


[axet@axet-laptop livecd]$ ./livecd.sh 
rm: cannot remove `*.iso': No such file or directory
/usr/lib/python2.6/site-packages/imgcreate/errors.py:40: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
  return str(self.message)
Traceback (most recent call last):
  File "/usr/bin/livecd-creator", line 140, in <module>
    sys.exit(main())
  File "/usr/bin/livecd-creator", line 112, in main
    ks = imgcreate.read_kickstart(options.kscfg)
  File "/usr/lib/python2.6/site-packages/imgcreate/kickstart.py", line 58, in read_kickstart
    "'%s' : %s" % (path, msg))
imgcreate.errors.KickstartError: Failed to read kickstart file '/home/axet/livecd/livecd.ks' : The following problem occurred on line 0 of the kickstart file:

Unable to open input kickstart file: Could not open/read file:///usr/share/spin-kickstarts/fedora-livecd-desktop.ks



patch:

<<<

    version = ksversion.makeVersion()
    ks = ksparser.KickstartParser(version)
    try:
        ksfile = urlgrabber.urlgrab(path)
        ks.readKickstart(ksfile)
    except IOError, (err, msg):

>>>

    version = ksversion.makeVersion()
    ks = ksparser.KickstartParser(version)
    try:
        ksfile = urlgrabber.urlgrab(path)
        ks.readKickstart(ksfile)
    except IOError, (msg):

Comment 1 Fedora Admin XMLRPC Client 2010-05-07 15:41:42 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 2 Bruno Wolff III 2010-07-24 20:33:56 UTC
I have a proposed patch for this awaiting review on the livecd list.

Comment 3 Jasper O'neal Hartline 2010-07-24 21:41:27 UTC
In response to Comment 2

I just applied the patch from the mailing list and it seems that to reproduce this issue you can provide an invalid %include in your base kickstart file to produce an IOError

The patch works fine in testing here.

I do have one concern, is this accurate error messages or is this a bug:

"Failed to read kickstart file 'livecd.ks'"
(It exists, it didn't fail to read it)

"The following problem occurred on line 0 of the kickstart file"
(Line 0 isn't where the include is at, which is incorrect, its line 11)


[root@ip70-190-121-13 tmp]# livecd-creator -c livecd.ks
Traceback (most recent call last):
  File "/usr/bin/livecd-creator", line 144, in <module>
    sys.exit(main())
  File "/usr/bin/livecd-creator", line 115, in main
    ks = imgcreate.read_kickstart(options.kscfg)
  File "/usr/lib/python2.6/site-packages/imgcreate/kickstart.py", line 58, in read_kickstart
    "'%s' : %s" % (path, ''.join(e.args[-1:])))
imgcreate.errors.KickstartError/usr/lib/python2.6/site-packages/imgcreate/errors.py:40: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
  return str(self.message)
: Failed to read kickstart file 'livecd.ks' : The following problem occurred on line 0 of the kickstart file:

Unable to open input kickstart file: Could not open/read file:///tmp/somefile.ks

[root@ip70-190-121-13 tmp]#

What do you think? livecd-creator bug or pykickstart?
I say commit what you have, investigate the accuracy of these later or file against the right component, which is pykickstart.

Comment 4 Mads Kiilerich 2010-07-25 00:28:57 UTC
As I said on http://lists.fedoraproject.org/pipermail/livecd/2010-July/006006.html : Definitely a pykickstart bug. But we might have to workaround it in livecd-tools.

Comment 5 Bruno Wolff III 2010-07-25 03:21:53 UTC
The line number stuff would be a bug in pykickstart.
Raising IOError with only one argument is also likely a bug in both pykickstart and urlgrabber. But the patch works by doing something reasonable with bad data.
I'll explain in more detail in responding to the NACK on list, to see if we can come to an agreement on this.

Comment 6 Bruno Wolff III 2010-07-25 14:24:21 UTC
A patch has been applied to master and a rebuild in rawhide should happen within a week.
I am also going to make sure urlgrabber and pykickstart have bugs filed for misusing the IOError exception.

Comment 7 Alan Pevec 2010-07-25 19:16:17 UTC
(In reply to comment #6)
> I am also going to make sure urlgrabber and pykickstart have bugs filed for
> misusing the IOError exception.    

When you have them, please put them here in Depends on:

Comment 8 Jasper O'neal Hartline 2010-07-26 02:30:38 UTC
Well. Here is a brief check of urlgrabber IOError and OSError contains:

[autopsy@ip70-190-121-13 urlgrabber]$ cat *.py | grep IOError
class RangeError(IOError):
            raise IOError('seek from end of file not supported.')
            raise IOError, ('ftp error', 'no host given')
            raise IOError, ('ftp error', msg), sys.exc_info()[2]
                raise IOError, ('ftp error', reason), sys.exc_info()[2]
                    raise IOError, ('ftp error', reason), sys.exc_info()[2]
class URLGrabError(IOError):
        4    - IOError on fetch
        IOError.__init__(self, *args)
        except IOError, e:
                err = URLGrabError(4, _('IOError on %s: %s') % (self.url, e))
            except IOError, e:
                  'error opening local file from %s, IOError: %s') % (self.url, e))
            except IOError, e:
                  'error opening file from %s, IOError: %s') % (self.url, e))
            except IOError, e:
                raise URLGrabError(4, _('IOError on %s: %s') %(self.url, e))
    except: # IOError
[autopsy@ip70-190-121-13 urlgrabber]$

[autopsy@ip70-190-121-13 urlgrabber]$ cat *.py | grep OSError
        5    - OSError on fetch
            except OSError:
        except OSError, e:
                except OSError, e:
                      'error setting timestamp on file %s from %s, OSError: %s') 
[autopsy@ip70-190-121-13 urlgrabber]$


==============================================================================
This for pykickstart:

[autopsy@ip70-190-121-13 pykickstart]$ cat *.py | grep IOError
            raise IOError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file: %s") % e.strerror)
        raise IOError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)
                    except IOError:
            raise IOError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)
[autopsy@ip70-190-121-13 pykickstart]$

[autopsy@ip70-190-121-13 pykickstart]$ cat *.py | grep OSError
[autopsy@ip70-190-121-13 pykickstart]$


Is there anywhere else we need to be looking?

Comment 9 Bruno Wolff III 2010-07-26 03:07:32 UTC
I added the bugs in case you want to keep this one open until those are resolved. When (if) they are, we will be able take out the fall back to args[0].

Comment 10 Mads Kiilerich 2010-07-26 09:17:54 UTC
Jasper, I think that http://lists.fedoraproject.org/pipermail/livecd/2010-July/006006.html lists all the problematic exceptions. I don't see any other issues of importance in your list.

The non-numerical 'ftp error' as errno might be surprising, and raising IOError (URLGrabError) with a hardcoded errno might cause problems somewhere, but none of these are bugs nor likely to cause any problems for livecd-tools.

Comment 11 Bruno Wolff III 2010-07-27 10:49:55 UTC
livecd-tools-033-1 has been built for rawhide and should fix this. (On the livecd-tools side.)

Comment 12 Jasper O'neal Hartline 2010-08-07 19:19:25 UTC
*** Bug 575564 has been marked as a duplicate of this bug. ***

Comment 13 Bruno Wolff III 2010-09-11 17:51:54 UTC
livecd-tools-033-1 is in stable for F14 and F13 and testing for F12.


Note You need to log in before you can comment on or make changes to this bug.