|
Meta tags:
description=This makes a couple related changes to inspect.signature s behaviour when parsing a signature from __text_signature__.
First, inspect.signature is documented as only raising ValueError or TypeError. However, in some cases, we could raise RuntimeError. This PR changes that, thereby fixing #83685.
(Note that the new ValueErrors in RewriteSymbolics are caught and then reraised with a message)
Second, inspect.signature could randomly drop parameters that it didn t understand (corresponding to return None in the p function). This is the core issue in #85267. I think this is very surprising behaviour and it seems better to fail outright.
Third, adding this new failure broke a couple tests. To fix them (and to e.g. allow inspect.signature(select.epoll.register) as in #85267), I add constant folding of a couple binary operations to RewriteSymbolics.
(There s some discussion of making signature expression evaluation arbitrary powerful in #68155. I think that s out of scope. The additional constant folding here is pretty straightforward, useful, and not much of a slippery slope)
Fourth, while #85267 is incorrect about the cause of the issue, it turns out if you had consecutive newlines in __text_signature__, you d get tokenize.TokenError.
Finally, the if name is invalid: code path was dead, since parse_name never returned invalid.
Issue: gh-85267;
Headings (most frequently used words):
uh, oh, navigation, gh, 85267, improvements, to, inspect, signature, __text_signature__, handling, 98796, there, for, footer, loading, this, diff, view, menu, repository, are, no, files, selected, viewing, filter, by, extension, hauntsaninja, oct, 28, 2022, edited, was, an, error, while, please, reload, page, choose, reason, hiding, comment,
Text of the page (most frequently used words):
self (30), file (25), this (24), signature (24), #inspect (22), func (19), github (16), and (16), valueerror (13), #reload (13), line (12), 2022 (12), ast (12), value (12), for (12), applied (11), while (11), the (11), all (11), raise (11), there (11), loading (11), hauntsaninja (11), expand (10), def (10), error (10), __text_signature__ (10), node (10), that (9), please (9), show (9), hidden (9), characters (9), unicode (9), was (9), comment (9), sig (9), resolved (8), code (8), diff (8), page (8), assertequal (8), return (8), you (7), suggestion (7), cannot (7), right (7), suggestions (7), changes (7), open (7), 85267 (7), lib (7), constant (7), isinstance (7), sign (7), not (6), improvements (6), number (6), bidirectional (6), learn (6), issue (6), test (6), default (6), default_node (6), left (6), security (5), comments (5), from (5), add (5), exc (5), parameters (5), handling (5), more (5), about (5), view (5), with (5), str (5), name (5), test_inspect (5), none (5), support (5), commits (5), your (5), can (4), pull (4), marked (4), change (4), lines (4), runtimeerror (4), fixes (4), text (4), what (4), review (4), next (4), rst (4), down (4), conversation (4), thread (4), sys (4), args (4), kwargs (4), hide (4), quality (4), split (4), files (4), nov (4), another (4), copilot (4), community (3), navigation (3), now (3), request (3), batch (3), commit (3), only (3), tokenize (3), original (3), contains (3), may (3), interpreted (3), compiled (3), differently (3), than (3), appears (3), below (3), editor (3), reveals (3), desktop (3), delete (3), edit (3), misc (3), news (3), library (3), xuy_wm (3), additions (3), assertraises (3), append (3), visit (3), wrap_value (3), reason (3), oct (3), whitespace (3), filter (3), 98796 (3), merged (3), python (3), account (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), has (2), outdated (2), single (2), one (2), viewing (2), invalid (2), toggle (2), raised (2), these (2), binary (2), operations (2), case (2), where (2), deletions (2), see (2), 4246 (2), exp (2), maxsize (2), 2480 (2), empty (2), except (2), rewritesymbolics (2), try (2), name_node (2), elif (2), 2223 (2), 2213 (2), visit_attribute (2), message (2), choose (2), hiding (2), copy (2), 2199 (2), generator (2), encode (2), ascii (2), 2100 (2), selected (2), apply (2), unified (2), failed (2), load (2), retry (2), jump (2), nbsp (2), extension (2), jellezijlstra (2), dec (2), main (2), into (2), update (2), select (2), tree (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), products (2), secret (2), perform, action, time, share, personal, information, manage, cookies, docs, 2026, inc, check, back, later, queued, multi, pending, reviews, been, must, existing, order, create, valid, applying, deleted, supported, per, subset, closed, because, were, made, annotations, notes, removed, dead, path, documented, raising, typeerror, but, sometimes, cases, allows, understand, defaults, involving, constants, tokenerror, dropped, several, __text_signature, ann_module7, import, bufferedreader, 43118, test_base_class_have_text_signature, 123, does_not_exist, assertisnotnone, test_callable, object, assertnotin, local, false, deletion, non, keyword, parameter, kind, annotation, builtin, format, obj, literal_eval, _empty, parse_name, bitor, sub, commonly, used, define, values, signatures, folding, couple, simple, visit_binop, visit_name, join, reversed, attr, class, nodetransformer, int, float, bytes, bool, type, reactions, sorry, something, went, wrong, get, caught, l2254, acquire, low, duplicate, off, topic, abuse, spam, will, displayed, describe, others, problem, author, contributor, markdown, link, edited, nameerror, eval, sys_module_dict, token_stream, iter, __next__, last_positional_only, self_parameter, _signature_strip_non_python_syntax, are, conversations, clear, filters, viewed, types, branch, fef9787, 126b8c3, runtime, 7f9f257, ea41f40, dd2e08f, blurb, bot, added, blurb_it, b60fb02, 16ae02e, hold, shift, click, range, changed, checks, already, clicking, agree, our, occasionally, send, related, emails, statement, service, free, its, maintainers, have, question, project, new, items, requests, issues, dismiss, alert, switched, accounts, out, appearance, settings, search, pricing, event, 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, source, latest, 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,
|