public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/_dyn_libs/
Date: Sun,  8 May 2011 21:31:19 +0000 (UTC)	[thread overview]
Message-ID: <e4320c84c71d61b41ba9c6016b06030ba1620a2f.zmedico@gentoo> (raw)

commit:     e4320c84c71d61b41ba9c6016b06030ba1620a2f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May  8 21:31:11 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May  8 21:31:11 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e4320c84

PreservedLibsRegistry: normalize counter as str

---
 .../util/_dyn_libs/PreservedLibsRegistry.py        |   26 ++++++++++++++++---
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
index 3fb8120..838cbaa 100644
--- a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
+++ b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
@@ -3,6 +3,7 @@
 
 import errno
 import logging
+import sys
 
 try:
 	import cPickle as pickle
@@ -12,6 +13,7 @@ except ImportError:
 from portage import os
 from portage import _encodings
 from portage import _os_merge
+from portage import _unicode_decode
 from portage import _unicode_encode
 from portage.exception import PermissionDenied
 from portage.localization import _
@@ -20,6 +22,9 @@ from portage.util import writemsg_level
 from portage.versions import cpv_getkey
 from portage.locks import lockfile, unlockfile
 
+if sys.hexversion >= 0x3000000:
+	basestring = str
+
 class PreservedLibsRegistry(object):
 	""" This class handles the tracking of preserved library objects """
 	def __init__(self, root, filename):
@@ -91,6 +96,17 @@ class PreservedLibsRegistry(object):
 		else:
 			self._data_orig = self._data.copy()
 
+	def _normalize_counter(self, counter):
+		"""
+		For simplicity, normalize as a unicode string
+		and strip whitespace. This avoids the need for
+		int conversion and a possible ValueError resulting
+		from vardb corruption.
+		"""
+		if not isinstance(counter, basestring):
+			counter = str(counter)
+		return _unicode_decode(counter).strip()
+
 	def register(self, cpv, slot, counter, paths):
 		""" Register new objects in the registry. If there is a record with the
 			same packagename (internally derived from cpv) and slot it is 
@@ -99,19 +115,21 @@ class PreservedLibsRegistry(object):
 			@type cpv: CPV (as String)
 			@param slot: the value of SLOT of the given package instance
 			@type slot: String
-			@param counter: vdb counter value for the package instace
-			@type counter: Integer
+			@param counter: vdb counter value for the package instance
+			@type counter: String
 			@param paths: absolute paths of objects that got preserved during an update
 			@type paths: List
 		"""
 		cp = cpv_getkey(cpv)
 		cps = cp+":"+slot
+		counter = self._normalize_counter(counter)
 		if len(paths) == 0 and cps in self._data \
-				and self._data[cps][0] == cpv and int(self._data[cps][1]) == int(counter):
+				and self._data[cps][0] == cpv and \
+				self._normalize_counter(self._data[cps][1]) == counter:
 			del self._data[cps]
 		elif len(paths) > 0:
 			self._data[cps] = (cpv, counter, paths)
-	
+
 	def unregister(self, cpv, slot, counter):
 		""" Remove a previous registration of preserved objects for the given package.
 			@param cpv: package instance whose records should be removed



             reply	other threads:[~2011-05-08 21:31 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-08 21:31 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-05-25 16:12 [gentoo-commits] proj/portage:master commit in: pym/portage/util/_dyn_libs/ Zac Medico
2018-01-02 23:04 Zac Medico
2016-12-27 21:43 Zac Medico
2016-06-06 16:03 Zac Medico
2015-06-02  3:48 Zac Medico
2015-04-24 17:53 Zac Medico
2013-03-18 23:43 Zac Medico
2013-03-18 23:35 Zac Medico
2013-02-22 18:52 Arfrever Frehtes Taifersar Arahesis
2012-03-22 15:24 Zac Medico
2012-03-21 21:24 Zac Medico
2012-03-05  7:32 Zac Medico
2012-02-18  3:11 Zac Medico
2012-02-18  2:06 Zac Medico
2012-02-01  2:04 Zac Medico
2011-07-24  2:58 Zac Medico
2011-07-24  2:58 Zac Medico
2011-07-24  2:15 Zac Medico
2011-07-23  6:23 Zac Medico
2011-07-22 20:38 Zac Medico
2011-07-22  8:03 Zac Medico
2011-07-20  8:05 Zac Medico
2011-07-20  4:51 Zac Medico
2011-07-01  4:02 Zac Medico
2011-07-01  4:02 Zac Medico
2011-07-01  1:37 Zac Medico
2011-06-30 10:17 Zac Medico
2011-06-30 10:01 Zac Medico
2011-05-08  7:10 Zac Medico
2011-05-08  5:02 Zac Medico
2011-05-07 17:25 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e4320c84c71d61b41ba9c6016b06030ba1620a2f.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox