From a197309e214ad060cd5f084ab47f6d04f09cf68b Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 17 Dec 2012 06:02:01 -0500 Subject: [PATCH] generator rejection --- requests/models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/requests/models.py b/requests/models.py index 741959a..d77ade5 100644 --- a/requests/models.py +++ b/requests/models.py @@ -9,12 +9,13 @@ This module contains the primary objects that power Requests. # import os # import socket + import collections import logging # from datetime import datetime from io import BytesIO - +from types import GeneratorType from .hooks import dispatch_hook, default_hooks from .structures import CaseInsensitiveDict from .status_codes import codes @@ -305,7 +306,10 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): def prepare_body(self, data, files): """Prepares the given HTTP body data.""" - # if a generator is provided, error out. + + # If a generator is provided, error out. + if isinstance(data, types.GeneratorType) + raise NotImplementedError('Generator bodies are not supported yet.') # Nottin' on you. body = None -- 2.34.1