Warning: Error with navigation contributor "BrowserModule"

Ticket #230 (closed defect: fixed)

Opened 17 months ago

Last modified 11 months ago

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.

Change History

comment:1 Changed 11 months ago by ferringb

  • Status changed from new to closed
  • Resolution set to fixed

for #1, the reasoning for deriving from a base exception is the same reason they rebased their exceptions to BaseException?- ability to grab the master/true-parent-exception, and intercept all exceptions of that class.

That said, renaming it isn't too hard- it's now BaseError? (name fits the derivatives format better also).

As for #2, can't replicate the warning. The "less is more" bit does apply, just need to do some serious reshuffling of pmerge code (and exception pass down) to make that prettier...

Marking fixed for #1, and due to not being able to replicate #2...

Note: See TracTickets for help on using tickets.