From ce80e0d2001e9a93c544ce9a4e049dd80b080cc9 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Mon, 5 Oct 2009 21:32:36 +0200 Subject: [PATCH] [entropy.misc/entropy.transceivers] use const_isfileobj --- libraries/entropy/misc.py | 5 +++-- libraries/entropy/transceivers.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/entropy/misc.py b/libraries/entropy/misc.py index a9cc07ea9..1d7ce6808 100644 --- a/libraries/entropy/misc.py +++ b/libraries/entropy/misc.py @@ -22,7 +22,8 @@ else: import urllib2 UrllibBaseHandler = urllib2.BaseHandler import threading -from entropy.const import etpConst, etpUi, const_isunicode, const_isstring +from entropy.const import etpConst, etpUi, const_isunicode, const_isstring, \ + const_isfileobj from entropy.core.settings.base import SystemSettings class Lifo: @@ -1168,7 +1169,7 @@ class MultipartPostHandler(UrllibBaseHandler): v_vars = [] try: for (key, value) in list(data.items()): - if isinstance(value, file): + if const_isfileobj(value): v_files.append((key, value)) else: v_vars.append((key, value)) diff --git a/libraries/entropy/transceivers.py b/libraries/entropy/transceivers.py index 2974ca1e3..e089e8924 100644 --- a/libraries/entropy/transceivers.py +++ b/libraries/entropy/transceivers.py @@ -20,7 +20,7 @@ else: import urllib2 as urlmod_error import time -from entropy.const import etpConst, const_isstring +from entropy.const import etpConst, const_isstring, const_isfileobj from entropy.output import TextInterface, darkblue, darkred, purple, blue, \ brown, darkgreen, red, bold from entropy.exceptions import * @@ -110,7 +110,7 @@ class UrlFetcher: # if client uses this instance more than # once, make sure we close previously opened # files. - if isinstance(self.localfile, file): + if const_isfileobj(self.localfile): try: self.localfile.flush() self.localfile.close() @@ -315,7 +315,7 @@ class UrlFetcher: def __close(self, errored): try: - if isinstance(self.localfile, file): + if const_isfileobj(self.localfile): self.localfile.flush() self.localfile.close() except IOError: