From 2c8a5f05bd9dded7a33cdc0ef3393c2ba8f9cf27 Mon Sep 17 00:00:00 2001 From: liaoxiaorong Date: Tue, 22 Dec 2015 12:18:38 +0800 Subject: [PATCH] raise ValueError if supply both a request object and **kwargs --- tornado/httpclient.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tornado/httpclient.py b/tornado/httpclient.py index 394c7fb1c..90c78119b 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -228,12 +228,8 @@ class AsyncHTTPClient(Configurable): if not isinstance(request, HTTPRequest): request = HTTPRequest(url=request, **kwargs) else: - for k, v in kwargs.items(): - try: - getattr(request, k) - except Exception as e: - raise ValueError('HTTPRequest get an unexcept kwags %s' % k) - setattr(request, k, v) + if kwargs: + raise ValueError("kwargs can't be used if request is an HTTPRequest object") # We may modify this (to add Host, Accept-Encoding, etc), # so make sure we don't modify the caller's object. This is also # where normal dicts get converted to HTTPHeaders objects. -- 2.47.2