|
Meta tags:
description=If:
stdin is in line buffer mode
the readline module is not loaded
not on windows
a GUI toolkit has installd PyOS_InputHook
Then, if the user enters lines longer than 98 characters into input:
user calls input(...)
user types/pastes a line longer than 98 characters + 1 newline
PyOS_InputHook returns
the first 99 characters are returned
the last character is not a new line so we go back to my_fgets
the PyOS_InputHook blocks because despite there being value in the buffer, stdin does not flag itself as ready to be read again
user hits enter again and to finish reading the input
the extra new line comes out the next time the user calls input
This fixes this bug by passing the currently read number of characters to my_fgets to skip the input hook when reading out a long buffer.
closes #103929
Qustions:
I do not know how to test this other than manually
It seems to work when stdin is unbuffered, but I do not fully understand why
Is the edit to the docs of PyOS_InputHook correct?
Issue: gh-103929;
Headings (most frequently used words):
navigation, uh, oh, gh, 103929, handle, long, input, lines, with, pyos_inputhook, 103931, are, footer, you, diff, view, menu, repository, there, no, files, selected, for, viewing, sure, want, to, change, the, base, filter, by, extension,
Text of the page (most frequently used words):
file (29), the (18), github (16), this (15), and (15), line (12), applied (11), #pyos_inputhook (11), for (11), that (10), show (10), you (9), loading (9), hidden (9), characters (9), unicode (9), open (9), code (8), all (8), reload (8), diff (8), suggestion (7), cannot (7), suggestions (7), while (7), comments (7), change (7), lines (7), 103929 (7), rst (7), sign (7), changes (6), expand (6), long (6), number (6), bidirectional (6), review (6), tacaswell (6), with (6), commits (6), not (5), security (5), 2026 (5), from (5), below (5), may (5), learn (5), about (5), view (5), input (5), issue (5), python (5), base (5), your (5), can (4), please (4), pull (4), add (4), there (4), what (4), more (4), next (4), doc (4), files (4), load (4), 103931 (4), handle (4), support (4), copilot (4), community (3), navigation (3), request (3), batch (3), commit (3), was (3), error (3), page (3), retry (3), down (3), null (3), tstate (3), see (3), my_fgets (3), original (3), contains (3), text (3), interpreted (3), compiled (3), differently (3), than (3), appears (3), editor (3), reveals (3), desktop (3), delete (3), edit (3), parser (3), myreadline (3), deletions (3), fix (3), news (3), core_and_builtins (3), inputhook (3), api (3), veryhigh (3), hide (3), whitespace (3), filter (3), branch (3), refname (3), account (3), quality (3), another (3), tab (3), window (3), refresh (3), session (3), developers (3), changelog (3), customer (3), enterprise (3), grade (3), features (3), build (3), contact (2), status (2), privacy (2), terms (2), footer (2), merge (2), outdated (2), single (2), one (2), viewing (2), toggle (2), void (2), _py_ismaininterpreter (2), interp (2), 104668 (2), pyos_readlinefunctionpointer (2), comment (2), call (2), stderr (2), prompt (2), char (2), additions (2), function (2), source (2), event (2), 151 (2), are (2), selected (2), misc (2), apply (2), split (2), unified (2), failed (2), jump (2), nbsp (2), extension (2), 2025 (2), select (2), tree (2), old (2), default (2), could (2), tags (2), branches (2), main (2), insights (2), projects (2), actions (2), repository (2), cpython (2), signed (2), universe (2), training (2), integrations (2), stories (2), center (2), documentation (2), business (2), fixes (2), products (2), secret (2), perform, action, time, share, personal, information, manage, cookies, docs, inc, right, now, check, back, later, queued, multi, pending, reviews, has, been, marked, resolved, must, existing, order, create, valid, applying, deleted, supported, only, per, subset, closed, invalid, because, were, made, annotations, notes, oops, something, went, wrong, keep, outside, repeatedly, fflush, fprintf, 318, 312, pyos_stdioreadline, sys_stdin, sys_stdout, const, clearerr, errno, endif, pythreadstate, buf, int, len, repeated, calls, var, addition, versionchanged, called, without, term, attached, thread, state, should, block, until, stdin, readable, loops, done, modules, _tkinter, same, library, runtime, using, conversations, clear, filters, viewed, types, pablogsal, jun, 3794d80, dec, mnt, move, loop, level, bea3f06, oct, additional, qualifier, expected, behavior, 7094a36, apr, 2023, c3a50dc, hold, shift, click, range, changed, checks, conversation, wants, into, pyos_inputhook_longlines, some, removed, timeline, become, sure, want, nothing, found, choose, already, clicking, agree, our, occasionally, send, related, emails, statement, service, free, its, maintainers, have, question, project, new, items, requests, issues, message, dismiss, alert, switched, accounts, out, appearance, settings, search, pricing, talks, workshops, partners, company, forum, events, webinars, blog, resource, connect, resources, premium, advanced, ons, trust, why, evaluate, industries, government, manufacturing, financial, services, healthcare, industry, nonprofits, startups, team, enterprises, stage, businesses, latest, improvements, across, place, developer, articles, sponsors, trending, repos, explore, customize, certifications, scanning, leak, prevention, protection, vulnerability, detection, remediation, secure, cloud, development, environments, codespaces, analysis, enforcement, automation, ship, coding, agent, tasks, automated, work, hosting, collaboration, platform, menu, skip, content,
|