forked from pool/rpmlint
Dirk Mueller
0b80e184d3
OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=543
40 lines
1.4 KiB
Diff
40 lines
1.4 KiB
Diff
From 49611f900047d5397ebbbdb0ed5299580337ea34 Mon Sep 17 00:00:00 2001
|
|
From: Dirk Mueller <dirk@dmllr.de>
|
|
Date: Wed, 1 Nov 2017 13:59:01 +0100
|
|
Subject: [PATCH] Avoid calling close on undefined fd variable
|
|
|
|
It can happen that open did through an OSError but then the
|
|
corresponding close UnknownVariableError wasn't caught. we
|
|
can fix that by putting both in the same try/exception block,
|
|
which also cleans up the code a bit.
|
|
---
|
|
Pkg.py | 9 ++-------
|
|
1 file changed, 2 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/Pkg.py b/Pkg.py
|
|
index 47197c9..2622f9a 100644
|
|
--- a/Pkg.py
|
|
+++ b/Pkg.py
|
|
@@ -719,16 +719,11 @@ class Pkg(AbstractPkg):
|
|
# use descriptor() method instead
|
|
try:
|
|
fd = os.open(pkgfile.path, os.O_RDONLY)
|
|
- except OSError:
|
|
- if not pkgfile.is_ghost:
|
|
- raise
|
|
- else:
|
|
pkgfile.magic = b2s(_magic.descriptor(fd))
|
|
- # libmagic up to 5.18 already closes the descriptor
|
|
- try:
|
|
os.close(fd)
|
|
except OSError:
|
|
- pass
|
|
+ if not pkgfile.is_ghost:
|
|
+ raise
|
|
if pkgfile.magic is None:
|
|
pkgfile.magic = ''
|
|
elif Pkg._magic_from_compressed_re.search(pkgfile.magic):
|
|
--
|
|
2.14.2
|
|
|