Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#12176 closed (invalid)

curry can't be replaced by functools.partial

Reported by: bear330 Owned by: nobody
Component: Template system Version: dev
Severity: Keywords: curry partial
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I think this should not be a bug.

I do this before:

# We make sure we are using Python 2.5, so partial is faster than
# django's curry function.
import functools
from django.utils import functional
functional.curry = functools.partial

This works fine at 1.0.2 and previous versions.

After I upgrade to 1.0.4, I got many problems while rendering template. I do some investigation, the problem is because

def _render_value_in_context(value, context):
    """
    Converts any value to a string to become part of a rendered template. This
    means escaping, if required, and conversion to a unicode object. If value
    is a string, it is expected to have already been translated.
    """
    value = force_unicode(value)
    if (context.autoescape and not isinstance(value, SafeData)) or isinstance(value, EscapeData):
        return escape(value)
    else:
        return value

While rendering node, force_unicode a SafeString will raise error.

I am just curious, why can't I replace curry with functools.partial?

Thanks.

Change History (2)

comment:1 by Luke Plant, 15 years ago

Resolution: invalid
Status: newclosed

I don't know, you tell me :-)

Since you include no information about how you are actually using curry/partial, or with what values, it's quite impossible for us to tell you. Also, this isn't a bug, and the bug tracker isn't the place for "just curious" questions I'm afraid.

in reply to:  1 comment:2 by anonymous, 15 years ago

Replying to lukeplant:

I don't know, you tell me :-)

Since you include no information about how you are actually using curry/partial, or with what values, it's quite impossible for us to tell you. Also, this isn't a bug, and the bug tracker isn't the place for "just curious" questions I'm afraid.

Actually, I don't "use" it. I just do functional.curry = functools.partial, then django broken.
While rendering templates, it will raise error because SafeString (which uses curry: decode = curry(_proxy_method, method = str.decode)) can't be pass to force_unicode function.

Finally, I am sorry to put a such question here, but I think this "MIGHT" be a problem, but I am not sure and curious. :)

Note: See TracTickets for help on using tickets.
Back to Top