Ticket #230 (closed defect: fixed)
pkgcore/config/errors.py DeprecationWarning etc
| Reported by: | djanderson | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | pkgcore | Version: | 0.4.7.16 |
| Keywords: | Cc: |
Description
There are a few small problems in config/errors.py:
Most of the problems stem from this: http://www.python.org/dev/peps/pep-0352/
1) Use of class BaseException(Exception):. From Python 2.5 onward, BaseException? is the name of Python's base exception, which includes Exception in this manner:
- BaseException
|- KeyboardInterrupt
|- SystemExit
|- Exception
|- (all other current built-in exceptions)
So even though pkgcore normally calls this as errors.BaseException?, I think it would be better to use a different name like PkgcoreException? or, since it's an empty exception, just raise Exception('something') directly in the code that currently raises BaseException? and inherit Exception instead of BaseException? in TypeDefinition? and ConfigutationException?.
2) The use of self.message is deprecated. Steps to reproduce:
# echo "=in-valid/atom" >>/etc/portage/package.keywords # pmerge /usr/lib/python2.6/site-packages/pkgcore/config/errors.py:88: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6 self.message = message /usr/lib/python2.6/site-packages/pkgcore/config/errors.py:97: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6 if self.message is not None: Error in configuration: Instantiating default domain 'livefs domain': Caught exception "domain failure: failed reading '/etc/portage/package.keywords': atom '=in-valid/atom' is malformed: error operator requires a version" instantiating pkgcore.ebuild.domain.domain
Not sure how to best deal with that, but I might recommend a little less is more in this situation, maybe just: "!!! failed reading '/etc/portage/package.keywords': atom '=in-valid/atom' is malformed: operator requires a version" would be more than enough information.
