From aae8f4ae2f48f9bdcb15b55584bf7db64c5f221c Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 3 Dec 2007 16:58:03 +0000 Subject: [PATCH] - Ensure fds are closed on exceptions (markmc, #404211) --- python-urlgrabber.spec | 7 ++++++- urlgrabber-3.0.0-cleanup.patch | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 urlgrabber-3.0.0-cleanup.patch diff --git a/python-urlgrabber.spec b/python-urlgrabber.spec index 9952361..215d3b8 100644 --- a/python-urlgrabber.spec +++ b/python-urlgrabber.spec @@ -3,10 +3,11 @@ Summary: A high-level cross-protocol url-grabber Name: python-urlgrabber Version: 3.0.0 -Release: 3%{?dist} +Release: 4%{?dist} Source0: urlgrabber-%{version}.tar.gz Patch0: urlgrabber-keepalive.patch Patch1: urlgrabber-string-type.patch +Patch2: urlgrabber-3.0.0-cleanup.patch License: LGPLv2+ Group: Development/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root @@ -24,6 +25,7 @@ authentication, proxies and more. %setup -q -n urlgrabber-%{version} %patch0 -p0 %patch1 -p1 +%patch2 -p1 %build python setup.py build @@ -43,6 +45,9 @@ rm -rf $RPM_BUILD_ROOT %{_bindir}/urlgrabber %changelog +* Mon Dec 3 2007 Jeremy Katz - 3.0.0-4 +- Ensure fds are closed on exceptions (markmc, #404211) + * Wed Oct 10 2007 Jeremy Katz - 3.0.0-3 - fix type checking of strings to also include unicode strings; fixes regets from yum (#235618) diff --git a/urlgrabber-3.0.0-cleanup.patch b/urlgrabber-3.0.0-cleanup.patch new file mode 100644 index 0000000..7a1ee05 --- /dev/null +++ b/urlgrabber-3.0.0-cleanup.patch @@ -0,0 +1,28 @@ +diff -up urlgrabber-3.0.0/urlgrabber/grabber.py.cleanup urlgrabber-3.0.0/urlgrabber/grabber.py +--- urlgrabber-3.0.0/urlgrabber/grabber.py.cleanup 2007-11-29 10:25:13.000000000 +0000 ++++ urlgrabber-3.0.0/urlgrabber/grabber.py 2007-11-29 10:26:15.000000000 +0000 +@@ -1204,16 +1204,18 @@ class URLGrabberFileObject: + bs = 1024*8 + size = 0 + +- if amount is not None: bs = min(bs, amount - size) +- block = self.read(bs) +- size = size + len(block) +- while block: +- new_fo.write(block) ++ try: + if amount is not None: bs = min(bs, amount - size) + block = self.read(bs) + size = size + len(block) ++ while block: ++ new_fo.write(block) ++ if amount is not None: bs = min(bs, amount - size) ++ block = self.read(bs) ++ size = size + len(block) ++ finally: ++ new_fo.close() + +- new_fo.close() + try: + modified_tuple = self.hdr.getdate_tz('last-modified') + modified_stamp = rfc822.mktime_tz(modified_tuple)