From a5fdf591cffaa787ac8c579f853e5ea8c20b4543 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 24 Dec 2012 12:20:58 -0800 Subject: porttree.py: tweak deprecated constructor params Trigger a DeprecationWarning even when None is passed in for one of the deprecated parameters, ensuring that any potentially unsafe usage triggers the warning. --- pym/portage/dbapi/porttree.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'pym/portage/dbapi') diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 9f0140cdf..35f4e2d09 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -65,7 +65,7 @@ class portdbapi(dbapi): return None return main_repo.eclass_db - def __init__(self, _unused_param=None, mysettings=None): + def __init__(self, _unused_param=DeprecationWarning, mysettings=None): """ @param _unused_param: deprecated, use mysettings['PORTDIR'] instead @type _unused_param: None @@ -81,7 +81,7 @@ class portdbapi(dbapi): from portage import settings self.settings = config(clone=settings) - if _unused_param is not None: + if _unused_param is not DeprecationWarning: warnings.warn("The first parameter of the " + \ "portage.dbapi.porttree.portdbapi" + \ " constructor is unused since portage-2.1.8. " + \ @@ -986,7 +986,8 @@ def close_portdbapi_caches(): portage.process.atexit_register(portage.portageexit) class portagetree(object): - def __init__(self, root=None, virtual=DeprecationWarning, settings=None): + def __init__(self, root=DeprecationWarning, virtual=DeprecationWarning, + settings=None): """ Constructor for a PortageTree @@ -1002,7 +1003,7 @@ class portagetree(object): settings = portage.settings self.settings = settings - if root is not None and root != settings['ROOT']: + if root is not DeprecationWarning: warnings.warn("The root parameter of the " + \ "portage.dbapi.porttree.portagetree" + \ " constructor is now unused. Use " + \ -- cgit v1.2.3-1-g7c22