Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

itertools segmentation fault #116980

Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
@pochmann3

Description

@pochmann3
Issue body actions

Crash report

What happened?

This code showing the first 20 Fibonacci numbers works fine:

from itertools import *

def Fibonacci():
    parts = [(0, 1)]
    whole = chain.from_iterable(parts)
    output, feedback = tee(whole)
    parts.append(map(sum, pairwise(feedback)))
    return output

print(*islice(Fibonacci(), 20))

Output (Attempt This Online!):

0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181

But if I keep a reference, it crashes (after successfully printing the numbers):

from itertools import *

def Fibonacci():
    parts = [(0, 1)]
    whole = chain.from_iterable(parts)
    output, feedback = tee(whole)
    parts.append(map(sum, pairwise(feedback)))
    return output

f = Fibonacci()
print(*islice(f, 20))

The error output (Attempt This Online!):

/ATO/runner: line 4:     2 Segmentation fault      (core dumped) /ATO/yargs %1 /ATO/options /ATO/yargs %2 /ATO/arguments python %1 /ATO/code %2 < /ATO/input

@rhettinger

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.12.0 (main, Oct 7 2023, 10:42:35) [GCC 13.2.1 20230801]

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.