Skip to content

PEP 750: TemplateIter is not pickleable #133216

Open
@sobolevn

Description

@sobolevn

Bug report

Right now you can't pickle string.templatelib.TemplateIter objects. I missed it during my pickle PR.

Demo:

>>> import pickle
>>> pickle.dumps(iter('abc'))
b'\x80\x05\x95"\x00\x00\x00\x00\x00\x00\x00\x8c\x08builtins\x94\x8c\x04iter\x94\x93\x94\x8c\x03abc\x94\x85\x94R\x94K\x00b.'

>>> pickle.dumps(iter(t'abc'))
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    pickle.dumps(iter(t'abc'))
    ~~~~~~~~~~~~^^^^^^^^^^^^^^
TypeError: cannot pickle 'string.templatelib.TemplateIter' object

I think that it should be fixed. I will send a PR with code and tests soon.

Metadata

Metadata

Assignees

Labels

3.14new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions