This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Infinite recursion in Pickler.persistent_id
Type: behavior Stage:
Components: Interpreter Core, Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: embe-navalgo, serhiy.storchaka
Priority: normal Keywords:

Created on 2021-11-02 08:21 by embe-navalgo, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
pickle-bug.py embe-navalgo, 2021-11-02 08:21
Messages (1)
msg405494 - (view) Author: Michał Bartoszkiewicz (embe-navalgo) Date: 2021-11-02 08:21
The following code, which seems reasonable:
import io
import pickle

class Pickler(pickle.Pickler):
  def persistent_id(self, obj):
    return super().persistent_id(obj)

Pickler(io.BytesIO()).dump(42)

crashes with:
RecursionError: maximum recursion depth exceeded while calling a Python object

It works perfectly when inheriting from pickle._Pickler (the Python implementation).
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89850
2021-11-02 09:16:16serhiy.storchakasetnosy: + serhiy.storchaka

components: + Interpreter Core
versions: + Python 3.11, - Python 3.7, Python 3.8
2021-11-02 08:21:56embe-navalgocreate