summaryrefslogtreecommitdiff
path: root/requests/utils.py
diff options
context:
space:
mode:
authorArthur Darcet <arthur.darcet@m4x.org>2014-12-12 16:11:32 +0100
committerArthur Darcet <arthur.darcet@m4x.org>2014-12-12 17:32:43 +0100
commite8d02ea0bbc05042e618a7ca115f4fca7b2deeb9 (patch)
tree44a1224b7f2ffcb47c71b4df4f499b98c1b5ac1c /requests/utils.py
parente23bf10cf4ecc62f6c3dd6284043516fb833d9ce (diff)
downloadpython-requests-e8d02ea0bbc05042e618a7ca115f4fca7b2deeb9.tar.gz
utils.guess_filename fails if the given parameter looks like a file object but has a non-string name attribute
e.g. a cherrypy uploaded file behave like a regular file, except that its name attribute is an int and passing it directly to requests fails because of that
Diffstat (limited to 'requests/utils.py')
-rw-r--r--requests/utils.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/requests/utils.py b/requests/utils.py
index aa5c140e..74679414 100644
--- a/requests/utils.py
+++ b/requests/utils.py
@@ -115,7 +115,7 @@ def get_netrc_auth(url):
def guess_filename(obj):
"""Tries to guess the filename of the given object."""
name = getattr(obj, 'name', None)
- if name and name[0] != '<' and name[-1] != '>':
+ if name and isinstance(name, builtin_str) and name[0] != '<' and name[-1] != '>':
return os.path.basename(name)