Repository navigation
build: complete the CPython notices (#2602 audit) - #2777
Merged
Merged
Conversation
Charter row R-NJ (a): read every Sharpy.Stdlib module with a CPython 3.15 namesake (55 modules) against its CPython source, plus the Core files that follow CPython's implementation, and notice every port. Ports (PSF header + THIRD-PARTY-NOTICES.txt entry): - Stdlib: Colorsys.cs; Difflib SequenceMatcher.cs, Differ.cs, DifflibFunctions.cs; Fraction.cs (limit_denominator); Threading Barrier.cs; Ipaddress AddressFormat.cs, IPv4Address.cs, IPv6Address.cs (borderline: __format__ and the _private_networks tables); Urllib UrllibModule.cs (borderline: uses_netloc/uses_params); spy-sourced fnmatch_module.spy, itertools.spy (borderline: the docs' equivalents), os_module.spy and shutil_module.spy (borderline), with their generated C#. - Core: PyFormatSpec.cs (parse_internal_render_format_spec), FloorDiv.cs and FloorMod.cs (_float_div_mod / float_rem), NumericText.cs (borderline: _PyUnicode_TransformDecimalAndSpaceToASCII), UnicodeCodec.cs (borderline: encodings.aliases rows); PyFormat.cs's entry now also names RenderComplex (format_complex_internal's set-up). The other 44 namesake modules are behaviour-only; Str.cs and ThreadRegistry.cs stay behaviour-only. regenerate_spy_stdlib.sh carries a .spy file's leading # comment block into the generated C# as // lines, so the shipped C# keeps the notice; the generated files change only by those comment lines. The notices intro drops the "not yet exhaustive" sentence and its list of open files. test_third_party_notices.py gains STDLIB_CENSUS (module -> port | behaviour for every namesake module on disk) and a check that every listed file has a numbered entry. Mutation record (each red, then restored from a cp copy, then 45 passed): - fake src/Sharpy.Stdlib/Pickle/Pickle.cs: 1 failed (test_stdlib_census_is_complete_and_honoured: no STDLIB_CENSUS row) - Colorsys verdict port -> behaviour, header kept: 1 failed (census: verdict 'behaviour' but the file carries the header) - delete the "Licensed under" line of Colorsys.cs: 3 failed (claim scan, notices_and_headers_agree, census) - delete the numbered Colorsys entry: 1 failed (test_every_listed_file_has_an_entry) - delete the Colorsys line of the file list: 4 failed - regenerate with the notice carry disabled: 2 failed (notices_and_headers_agree, census); restored script, regenerated, green Refs #2602 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy
Review fixes for PR #2777. STDLIB_CENSUS rows now carry the exact set of headed files a port module holds (paths under src/Sharpy.Stdlib): "Difflib": port( "Difflib/SequenceMatcher.cs", "Difflib/Differ.cs", "Difflib/DifflibFunctions.cs"). census_problems asserts the module's headed set equals the recorded set, so a lost header and an extra one are both red. It also refuses a port row with no files, a behaviour row with files, and a row naming a file outside its module, and it requires each port file to be listed in THIRD-PARTY-NOTICES.txt. New synthetic tests cover a lost header in a multi-file port, an extra header in a port module, and the three row-shape refusals. Mutation records (restored from cp copies, never git): - M4 (the reviewer's): strip SequenceMatcher.cs's whole leading comment block (the "port of" line too, so the claim scan stays silent), its file-list line and its name in entry 10. Red: test_stdlib_census_is_complete_and_honoured, with "Difflib/ SequenceMatcher.cs: in Difflib's port set but carries no PSF header" and "in a 'port' module but not listed" (1 failed, 49 passed). Restored -> 50 passed. - Extra header: put the PSF header lines on Difflib/__Init__.cs (a behaviour file in a port module), add it to the file list and to entry 10. Red: test_stdlib_census_is_complete_and_honoured, with "Difflib/__Init__.cs: carries the PSF header but is not in Difflib's port set" (1 failed, 49 passed). Restored -> 50 passed. Nits: UnicodeCodec.cs's header now names all ten codecs its alias table maps to (utf_8_sig and the _le/_be variants), matching entry 8. PyFormatSpec.cs's summary now says CPython 3.14, as its header does. The notices intro is scoped to the CPython audit. It no longer claims every third-party component is listed. Code or data from other upstreams is outside the audit, and no entry is added for it here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy
Second-review fix for PR #2777. The census comment claimed a file added to a port module is read like a new module, "header and row, or neither". It is not enforced. The census sees only headed files, so a new unheaded file in a port module stays green, and so does a row edited together with its header. The comment now says what is enforced: a port module's headed files equal its row's set, an unheaded file is not seen, and the row is the audit's record that review reads. census_problems also checks a row's shape before unpacking it. A bare "port", port(""), a 1-tuple or a list set now gets a named problem ("is not (verdict, set of file paths)") instead of a ValueError or IndexError, covered by test_census_names_a_malformed_row. Mutation: replaced the shape check's condition with "True or ..." so it never fires. Red: the 4 test_census_names_a_malformed_row cases (4 failed, 50 passed). Restored from a cp copy: 54 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy
This was referenced Nov 20, 2026
antonsynd
pushed a commit
that referenced
this pull request
Nov 20, 2026
The #2777 review found one-line API summaries copied word for word from CPython 3.15 Lib docstrings, mostly in files the #2602 census marks "behaviour". They are documentation, not code, so the files keep no PSF header; THIRD-PARTY-NOTICES.txt gains one section in the CPython part, "API documentation summaries adapted from CPython docstrings", naming the 17 files (40 summaries: 33 in behaviour files, 7 in the fnmatch and shutil ports), the Lib modules they come from, and the PSF licence text that follows by reference. Method (the reviewer's): a summary matches when its first paragraph (a C# <summary>: its whole text or first sentence), whitespace collapsed, case and a final full stop ignored, equals the first paragraph of a module, class or function docstring longer than 30 characters in CPython 3.15.2's Lib (test packages, idlelib, site-packages not read); C# generated from a .spy file is skipped. No later sentence of a matched summary appears in a CPython docstring. Guard: test_third_party_notices.py runs that matcher over Sharpy.Core and Sharpy.Stdlib against python3.15's Lib (the pytest interpreter when it is 3.15, else python3.15 on PATH, else skip with a reason) and requires the section's list to equal the matched set. Unit tests pin the index rule and both refusal directions without the oracle. Mutations: (a) drop src/Sharpy.Stdlib/spy/heapq.spy from the section: red (1 failed, 60 passed: "heapq.spy: holds CPython docstring text ... but is not under 'Sharpy files holding these summaries:'"); (b) bisect_module.spy's module docstring replaced by bisect.insort's "Insert item x in list a, and keep it sorted assuming a is sorted.": red (1 failed, 60 passed: "bisect_module.spy: holds CPython docstring text ... <- Lib/bisect.py"); each restored with cp + cmp: green (61 passed). Refs #2602 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy
antonsynd
pushed a commit
that referenced
this pull request
Nov 20, 2026
The #2777 review found two derived pieces from non-CPython sources: - src/Sharpy.Core/StringExtensions.Format.cs: the case-folding table (s_caseFoldTable) and the Cherokee ranges in CaseFoldChar, from the Unicode Character Database's CaseFolding.txt. The source records no version; all 125 entries equal CPython 3.15.2's str.casefold, which uses Unicode 17.0.0. - src/Sharpy.Stdlib/Yaml/YamlScalarResolver.cs: Yaml11Int and Yaml11Float, transcribed from PyYAML 6.0.3's implicit resolvers (lib/yaml/resolver.py; checked against the 6.0.3 tag's file). THIRD-PARTY-NOTICES.txt gains a section for each (upstream, version, derived portion, full licence text), placed before the CPython section so the CPython licence stays the file's last 277 lines. Each file gains a short header naming its upstream and pointing at the notices. The intro now says the #2602 audit covered CPython, names these two sources as also listed, and claims no other completeness. Licence texts, fetched 2026-11-20: - PyYAML: https://raw.githubusercontent.com/yaml/pyyaml/6.0.3/LICENSE (sha256 8d3928f9...a577e8a4), verbatim. - Unicode License V3: https://www.unicode.org/license.txt was refused by the network proxy (403); the text is the first section of https://raw.githubusercontent.com/unicode-org/icu/main/LICENSE (the Unicode Consortium's repository), verbatim, and differs from SPDX's Unicode-3.0 text (spdx/license-list-data) only in the copyright years (1991-2026 against 1991-2023). No PackageLicenseExpression changes (the owner's call). Refs #2602 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGMKZYKjCq2pTmNWtKf2hy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Charter R-NJ (a); owner, 2026-11-20: "file a lane for the #2602 notices audit too".
THIRD-PARTY-NOTICES.txtsaid its list was "not yet exhaustive". This audit read every Sharpy.Stdlib module with a CPython 3.15 namesake (55 modules) against its CPython source: Lib at 3.15.2, C sources andDoc/atv3.14.0. It also read the Core files that follow CPython. The compiler, CLI and LSP have no ported code (comments only).How each module was judged:
Change
Each port file now carries the PSF header lines plus "Portions…" and "Changes:" comments, and has a numbered
THIRD-PARTY-NOTICES.txtentry. Each entry names the derived portions and the clause-3 changes.Colorsys/Colorsys.csDifflib/SequenceMatcher, Differ, DifflibFunctions__chain_b,find_longest_match,_fancy_replace, unified/context diff, IS_LINE_JUNKfnmatch_module.spy+ generated C#translate's bracket scanFractions/Fraction.cslimit_denominatorloop and messageThreading/Barrier.csIpaddress/AddressFormat, IPv4Address, IPv6Address__format__step for step; the private/public network tablesitertools.spy+ generated C#os_module.spy+ generated C#makedirsrecursion; walk's push ordershutil_module.spy+ generated C#_destinsrc,_basename,movefallbackUrllib/UrllibModule.csuses_netloc/uses_paramstables onlyPyFormatSpec.csparse_internal_render_format_spec, refusal order and messagesFloorDiv.cs,FloorMod.cs_float_div_mod/float_remPyFormat.csformat_complex_internalNumericText.cs_PyUnicode_TransformDecimalAndSpaceToASCIIUnicodeCodec.csThe other 44 namesake modules,
Str.csandThreadRegistry.csare behaviour-only. Examples: .NET wrappers, a parser of our own, textbook algorithms.Datetime/DatetimeIso.csandFraction.Format.csalready had notices.Spy-sourced modules:
build_tools/regenerate_spy_stdlib.shnow copies a.spyfile's leading#comment block into the generated C# as//lines. The shipped C# therefore keeps the notice. Regenerated files change only by those comment lines.The notices intro drops "This list is not yet exhaustive" and its list of open files.
Packaging: every port is in Sharpy.Core or Sharpy.Stdlib. Both packages ship
THIRD-PARTY-NOTICES.txtand declarePython-2.0. SharpyLang.Compiler only references Core as a project, so no ported source goes into its package.Guard
build_tools/tests/test_third_party_notices.py:STDLIB_CENSUS: an exact map from each of the 55 namesake module directories toportorbehaviour.test_stdlib_census_is_complete_and_honoured:sys.stdlib_module_names);test_every_listed_file_has_an_entry: the notices' file list and its numbered entries agree.Mutation record
Each mutation was restored from a
cpcopy afterwards → 45 passed.Pickle/Pickle.csmoduleport→behaviour, keeping its headerGate
Local @
caea032f1(lane worker, measured):build_tools/tests: 2,224 passed, 3 failed. Two are the review-line history tests, which fail the same way atorigin/devin a shallow clone (control run). One serialized-lock test was flaky under peer load and passed on rerun;stdlib generate --checkand spy staleness: up to date;Conformance|Infrastructure18,518/0/0; whitespace clean.Merged with
origin/dev@11b0e95aa(merge tree7caa9871a, clean):test_package_licenses.pyandtest_third_party_notices.py53 passed. #2773's guard on the retired id stays green, since no new file names it.CI gate: 85,538 passed, 0 failed, 10 skipped @
e18faf213(measured,.NET 10run 44804483138); Python Build Tools 44804483154, review-line 44804549038 and subjects passed. A review-line run cancelled by its successor (44804483153) is not a failure.For the owner, not changed here
src/Sharpy.Stdlib/modules/are packable by default. They don't pack the notices and declareApache-2.0 OR MIT.release.ymldoesn't pack them today.Issues
Refs #2602. It closes after merge, on evidence (
/close-issues).Independent review
Independent review @ 3860626: merge; 2 applied, 0 declined (reasons below); fixes 3860626..e18faf2 read by the lead
First review @
caea032f1: merge after fixes. A fresh reviewer read the behaviour modules against CPython 3.15.2 Lib and the v3.14.0 C sources and Doc. It found no missed port, and judged every attribution reasonable, the borderline ones included. The header licence text is byte-identical to CPython's LICENSE. On a merge withdev, the licence and notices guards pass 53/53.Applied in
3860626d0:Sent to the owner, not changed here: docstring first lines copied from CPython into behaviour modules; the per-module Stdlib packages that ship no notices; Unicode CaseFolding.txt and PyYAML entries; and a crash found in passing,
Fraction(-1, 3).limit_denominator(2)throwingDivideByZeroException(CPython:-1/2; #2606's control row is wrong).Second review @
3860626d0: merge. The reviewer ran both mutations red. It tried a set naming a missing file, a different case or separator, a subdirectory, a.spy/C# header mismatch, and row-shape refusals: all red, or caught by the staleness gate. Fullbuild_tools/testson a merge withdev: 2,242 passed, 1 skipped, 0 failed. Applied ine18faf213:IndexError/ValueError. It is now a named problem, with a test of four shapes, mutation-tested: 4 red, then 54 green.Generated by Claude Code