[yum-git] yum/misc.py yum/yumRepo.py
James Antill
james at linux.duke.edu
Sat May 3 22:37:33 UTC 2008
yum/misc.py | 7 +++++++
yum/yumRepo.py | 8 ++++----
2 files changed, 11 insertions(+), 4 deletions(-)
New commits:
commit 18f2c7b0ef6837bfdb2d09e50cf1214ac61437af
Author: James Antill <james at and.org>
Date: Sat May 3 18:36:35 2008 -0400
Fix non-ascii package names to urlgrabber: bug#261961
Patch from: a.badger at gmail.com
This new patch creates a to_utf8() method like to_unicode() that only converts
if the object passed to it is unicode. Using it in _get_file() does the right
thing whether we are handing in a unicode or YumRepository.
diff --git a/yum/misc.py b/yum/misc.py
index 3c03cff..67b9171 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -536,6 +536,13 @@ def to_unicode(obj, encoding='utf-8', errors='replace'):
obj = unicode(obj, encoding, errors)
return obj
+def to_utf8(obj, errors='replace'):
+ '''convert 'unicode' to an encoded utf-8 byte string '''
+ if isinstance(obj, unicode):
+ obj = obj.encode('utf-8', errors)
+ return obj
+
+# Don't use this, to_unicode should just work now
def to_unicode_maybe(obj, encoding='utf-8', errors='replace'):
''' Don't ask don't tell, only use when you must '''
try:
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 3815ced..2780e85 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -626,8 +626,8 @@ class YumRepository(Repository, config.RepoConf):
remote = url + '/' + relative
try:
- result = ug.urlgrab(remote, local,
- text=text,
+ result = ug.urlgrab(misc.to_utf8(remote), local,
+ text=misc.to_utf8(text),
range=(start, end),
)
except URLGrabError, e:
@@ -640,8 +640,8 @@ class YumRepository(Repository, config.RepoConf):
else:
try:
- result = self.grab.urlgrab(relative, local,
- text = text,
+ result = self.grab.urlgrab(misc.to_utf8(relative), local,
+ text = misc.to_utf8(text),
range = (start, end),
copy_local=copy_local,
reget = reget,
More information about the Yum-cvs-commits
mailing list