|
Meta tags:
description=Ctypes currently produces wrong pep3118 type codes for several types.
E.g. memoryview(ctypes.c_long()).format gives l on 64-bit platforms,
but it should be q instead for sizeof(c_long) == 8
The problem is that the endian specification in the struct syntax
also turns on the standard size mode, which makes type characters have
a platform-independent meaning, which does not match with the codes used
internally in ctypes. The struct module format syntax also does not
allow specifying native-size non-native-endian items.
This commit adds a converter function that maps the internal ctypes
codes to appropriate struct module standard-size codes in the pep3118
format strings. The tests are modified to check for this..
(cherry picked from commit 07f1658)
htt????/bugs.python.org/issue10746;
Headings (most frequently used words):
uh, oh, for, navigation, bpo, 10746, fix, ctypes, pep, 3118, type, codes, c_long, c_bool, c_int, gh, 31, 3242, there, footer, loading, this, diff, view, menu, repository, are, no, files, selected, viewing, filter, by, extension, eamanu, aug, 30, 2017, edited, was, an, error, while, please, reload, page, choose, reason, hiding, comment,
Text of the page (most frequently used words):
none (55), pointer (38), the (27), file (25), this (21), and (20), for (17), pep_code (17), c_short (17), github (16), #c_long (16), break (15), that (14), case (14), s_long (14), ctypes (13), line (12), code (12), type (12), applied (11), all (11), sizeof__bool (11), expand (10), format (10), error (10), reload (10), c_int (10), you (9), show (9), hidden (9), characters (9), unicode (9), lepoint (9), replace (9), complete (9), c_bool (9), cannot (8), while (8), result (8), with (8), loading (8), pep (8), diff (8), bpo (8), 10746 (8), bepoint (8), structwitharrays (8), suggestion (7), suggestions (7), stgdict (7), there (7), 2017 (7), codes (7), open (7), c_ulong (7), c_uint (7), sizeof (7), sign (7), please (6), has (6), changes (6), null (6), endif (6), was (6), learn (6), elif (6), may (6), 3118 (6), number (6), bidirectional (6), _ctypes (6), incomplete (6), c_double (6), c_ulonglong (6), c_longlong (6), security (5), comments (5), change (5), pyobject (5), page (5), test (5), comment (5), more (5), sizeof_int (5), about (5), view (5), fix (5), structure (5), support (5), s_short (5), c_ushort (5), commits (5), your (5), can (4), not (4), pull (4), one (4), down (4), proto_str (4), else (4), unexpected (4), value (4), hide (4), quality (4), sizeof_long (4), char (4), types (4), contains (4), what (4), review (4), next (4), rst (4), aunion (4), emptystruct (4), point2 (4), packedpoint (4), point (4), c_float (4), c_byte (4), c_longdouble (4), s_ulong (4), files (4), copilot (4), community (3), navigation (3), request (3), from (3), add (3), batch (3), commit (3), _ctypes_alloc_format_string_for_type (3), string (3), copy (3), but (3), reason (3), original (3), text (3), interpreted (3), compiled (3), differently (3), than (3), appears (3), below (3), editor (3), reveals (3), desktop (3), delete (3), edit (3), modules (3), deletions (3), misc (3), news (3), library (3), nmavfu (3), endian (3), machines (3), class (3), s_longdouble (3), s_ulonglong (3), s_longlong (3), s_uint (3), s_int (3), lib (3), test_pep3118 (3), whitespace (3), nbsp (3), filter (3), 3242 (3), merged (3), python (3), account (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), later (2), been (2), resolved (2), outdated (2), single (2), viewing (2), because (2), toggle (2), _ctypes_alloc_format_string (2), getfunc (2), fmt (2), setfunc (2), non (2), into (2), returns (2), failure (2), allocate (2), memory (2), block (2), pep3118 (2), return (2), big_endian (2), standard (2), size (2), wrong (2), new (2), don (2), define (2), its (2), have (2), choose (2), hiding (2), aug (2), dict (2), 128 (2), additions (2), little (2), arrays (2), unions (2), structures (2), pointers (2), py_object (2), s_bool (2), alias (2), are (2), aliases (2), s_ushort (2), c_ubyte (2), c_char (2), s_double (2), platform (2), 109 (2), selected (2), apply (2), split (2), unified (2), failed (2), load (2), retry (2), jump (2), extension (2), sep (2), select (2), tree (2), issue (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, 2026, inc, right, now, check, back, queued, merge, multi, pending, reviews, marked, must, existing, order, create, valid, applying, deleted, lines, supported, only, per, subset, closed, invalid, were, made, annotations, notes, py_decref, ifdef, words_bigendian, 1999, 2070, pycsimpletype_new, pytypeobject, args, kwds, suffix, prefix, pymem_malloc, same, default, reactions, sorry, something, went, regard, really, sound, how, variable, searching, where, defining, found, defintion, pyconfig, never, including, solution, tools, here, problems, win, compilation, low, duplicate, off, topic, abuse, spam, will, displayed, describe, others, problem, contributor, markdown, link, edited, eamanu, thread, switch, int, static, since, endianness, need, swapped, native, produces, mode, struct, module, indicator, set, suitable, corresponding, given, filled, 292, 298, pydict_getitemproxy, key, maps, pyexc_argerror, undef, ifndef, have_c99_bool, definition, matching, cfield, 724, include, bytes, cdata, producing, integer, addition, __name__, __main__, endian_types, 193, 220, littleendianstructure, unfortunately, fixed, created, starts, completed, after, sub, does, packed, implement, bit, platforms, 117, 145, shape, calc, itemsize, native_types, definitions, __init__, s_float, specific, replaces, big, table, strings, they, look, conversations, clear, filters, viewed, ensure, defined, 33b7e42, a8c7223, hold, shift, click, range, changed, checks, conversation, backport, 07f1658, pitrou, already, clicking, agree, our, occasionally, send, related, emails, statement, service, free, maintainers, question, project, items, requests, issues, message, 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, see, industries, government, manufacturing, financial, services, healthcare, industry, nonprofits, startups, team, enterprises, stage, businesses, source, 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, menu, skip, content,
|