Opened 8 years ago

Last modified 3 years ago

#28223 new Bug

Form not always picklable due to template renderer

Reported by: Claude Paroz Owned by: nobody
Component: Forms Version: 1.11
Severity: Normal Keywords:
Cc: Torsten Bronger, Martin H., Matti Haavikko Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no
Pull Requests:How to create a pull request

Description

I'm confronted with a random pickling issue with some forms in Django 1.11.
The error is : PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed

I tracked the pickling error to the Form.renderer.engine.engine.template_libraries dict.

I can more or less reproduce (different error message, but hopefully same cause) with:

from django.forms.renderers import get_default_renderer
import pickle
renderer = get_default_renderer()
renderer.engine
pickle.dumps(renderer)

PicklingError: Can't pickle <function add_preserved_filters at 0x7f2468bfc620>: it's not the same object as django.contrib.admin.templatetags.admin_urls.add_preserved_filters

According to the ticket's flags, the next step(s) to move this issue forward are:

  • To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is: [https://github.com/django/django/pull/#### PR].

Change History (7)

comment:1 by Tim Graham, 8 years ago

Summary: Form not always picklableForm not always picklable due to template renderer
Triage Stage: UnreviewedAccepted

comment:3 by Carlton Gibson, 7 years ago

#29411 is a duplicate of this, with a slightly different reproduce case.

comment:4 by Torsten Bronger, 7 years ago

Cc: Torsten Bronger added

To copy over important information from duplicate:

This broke in 1.11 and had worked in 1.10 and before.

comment:6 by Tim Graham, 6 years ago

I believe template widget rendering (b52c73008a9d67e9ddbb841872dc15cdd3d6ee01 introduced this issue.

comment:7 by Martin H., 6 years ago

Cc: Martin H. added

comment:8 by Matti Haavikko, 4 years ago

Cc: Matti Haavikko added
Note: See TracTickets for help on using tickets.
Back to Top