Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickling recursion error, did not import pickle #88545

Closed
Octopi mannequin opened this issue Jun 10, 2021 · 3 comments
Closed

Pickling recursion error, did not import pickle #88545

Octopi mannequin opened this issue Jun 10, 2021 · 3 comments
Labels
3.8 only security fixes 3.10 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@Octopi
Copy link
Mannequin

Octopi mannequin commented Jun 10, 2021

BPO 44379
Nosy @terryjreedy, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2021-06-10.23:11:29.753>
created_at = <Date 2021-06-10.15:31:07.006>
labels = ['invalid', 'expert-IDLE', 'type-bug', '3.8', '3.10']
title = 'Pickling recursion error, did not import pickle'
updated_at = <Date 2021-06-10.23:11:29.752>
user = 'https://bugs.python.org/Octopi'

bugs.python.org fields:

activity = <Date 2021-06-10.23:11:29.752>
actor = 'terry.reedy'
assignee = 'none'
closed = True
closed_date = <Date 2021-06-10.23:11:29.753>
closer = 'terry.reedy'
components = ['IDLE']
creation = <Date 2021-06-10.15:31:07.006>
creator = 'Octopi'
dependencies = []
files = []
hgrepos = []
issue_num = 44379
keywords = []
message_count = 3.0
messages = ['395542', '395552', '395587']
nosy_count = 3.0
nosy_names = ['terry.reedy', 'serhiy.storchaka', 'Octopi']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue44379'
versions = ['Python 3.8', 'Python 3.10']

@Octopi
Copy link
Mannequin Author

Octopi mannequin commented Jun 10, 2021

I accidentally created an infinite recursion. The error referenced pickling but I did not import pickle.

To reproduce:
def permute(inputList):
'''permute(inputList) -> list
returns list of all permutations of inputList
CURRENTLY DOESN'T ACTUALLLY WORK PROPERLY'''
for i in range(len(inputList)-1):
tempList = inputList[:-i-2]
tempList.append(inputList[-1])
for num in inputList[-i-2:-1]:
tempList.append(num)
print(tempList)
permute(tempList) # runs infinitely (whoops)
print()

permute([1,2,3,4])
Error thrown: 
Traceback (most recent call last):
  File "C:\Users\Violet\Documents\Python Files\test.py", line 14, in <module>
    permute([1,2,3,4])
  File "C:\Users\Violet\Documents\Python Files\test.py", line 11, in permute
    permute(tempList)  # runs infinitely (whoops)
  File "C:\Users\Violet\Documents\Python Files\test.py", line 11, in permute
    permute(tempList)  # runs infinitely (whoops)
  File "C:\Users\Violet\Documents\Python Files\test.py", line 11, in permute
    permute(tempList)  # runs infinitely (whoops)
  [Previous line repeated 1009 more times]
  File "C:\Users\Violet\Documents\Python Files\test.py", line 10, in permute
    print(tempList)
RecursionError: maximum recursion depth exceeded while pickling an object

@Octopi Octopi mannequin assigned terryjreedy Jun 10, 2021
@Octopi Octopi mannequin added 3.8 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error labels Jun 10, 2021
@serhiy-storchaka
Copy link
Member

It is because you run the code in IDLE.

print(tempList) converts argument to string and write it to sys.stdout. In IDLE sys.stdout is a proxy object which uses RPC to communicate with the IDLE process which should insert the written text in the console text widget. Pickle is used for encoding command and arguments. Here you get a recursion error in pickle because when print(tempList) is executed the recursion depth almost reached the limit.

@terryjreedy
Copy link
Member

The 'while pickling' part of the message is specific to running in IDLE, as Serhiy explained, but the recursion error itself is due to writing a program with infinite recursion. The program switches the last two items back and forth indefinitely. When run directly in Python, it gives the same error, with a different 'while' part.

Violet, this tracker is for patching Python docs and the CPython interpreter. Please ask questions about program behavior elsewhere, such as python-list.

@terryjreedy terryjreedy added the 3.10 only security fixes label Jun 10, 2021
@terryjreedy terryjreedy removed their assignment Jun 10, 2021
@terryjreedy terryjreedy added the 3.10 only security fixes label Jun 10, 2021
@terryjreedy terryjreedy removed their assignment Jun 10, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.8 only security fixes 3.10 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants