Krasjet / Krasjet/pdf.tocgen

"ValueError: I/O operation on closed file." when debugging from the command line

Open
#39 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
848
Forks
31
PR merge metrics
No merged PRs in 30d

Description

# Summary
When trying to debug pdftocio (or pdftocio) using pdb and reading the TOC from a file, pdb crashes with "ValueError: I/O operation on closed file".

# Steps to reproduce
1. create a TOC file "test.toc" (contents don't matter) and have a PDF
2. run: `python -m pdb ${bindir}/pdftocio -t test.toc in.pdf`
3. from pdb, type `c`

# Cause
By default, the toc file is opened from `sys.stdin.buffer`. If a file is set with `-t`, stdin gets closed. pdb then tries to read from stdin to get the next command, causing the exception.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the reported command with Python's pdb and the pdftocio -t option. Then inspect the command-line path that opens the TOC from stdin and compare it with pdb's command input. Done means debugging can continue after entering c without a closed-file exception when -t test.toc is used.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.