Skip to content

Licence notices: audit files ported from CPython source #2602

Closed

Description

@antonsynd

Class: source files that describe themselves as ports of CPython source but carry no licence notice. Found while preparing and reviewing #2601, which adds THIRD-PARTY-NOTICES.txt for Datetime/DatetimeIso.cs only. CPython is under the PSF License Version 2, which asks a derivative work to retain the licence text and copyright notice and to summarise its changes.

File Its own claim Assessment Ships in
src/Sharpy.Stdlib/Fractions/Fraction.Format.cs:9 "an exact port of CPython 3.14's fractions.py" Real source port: _round_to_exponent / _round_to_figures translated function for function; line 30 carries a CPython comment word for word; lines 90 and 124 carry its format-spec regexes Stdlib, sharpyc
src/Sharpy.Core/PyFormat.cs:1379 "A port of CPython's _PyUnicode_InsertThousandsGrouping" Likely a real port (the loop follows the C grouping loop), small Core, Stdlib consumers, sharpyc, playground bundle
src/Sharpy.Core/PyFormatSpec.cs:72 parse and rule order are CPython's unicode_format.h / formatter_unicode.c Borderline: structure and rule order Core
src/Sharpy.Stdlib/Threading/Barrier.cs:20 "CPython's algorithm (Lib/threading.py), on one monitor" Borderline: same state machine, reimplemented Stdlib
src/Sharpy.Core/Str.cs:244 "ported from CPython's format_float_short" Probably behaviour only (one threshold rule) Core
src/Sharpy.Stdlib/Threading/ThreadRegistry.cs:8 "modelled on CPython 3.12's threading.py" Behaviour only Stdlib

Assessments are two agents' readings of the comments and code, not a legal judgment.

Owner decisions

  1. Which rows get a notice (header + an entry in THIRD-PARTY-NOTICES.txt). If any Core file does, Sharpy.Core.csproj must pack and publish the notices file too.
  2. Package licence metadata: Directory.Build.props sets PackageLicenseExpression to Apache-2.0 OR MIT and README.md says the same, while the Stdlib and sharpyc packages contain PSF-2.0 portions. A per-project expression such as (Apache-2.0 OR MIT) AND PSF-2.0 may be the accurate one.
  3. src/Sharpy.Stdlib.Tests/Spy/cpython/NOTICE uses the copyright years "2001-2024"; the licence text itself says "2001". Harmless, but inconsistent.

Mechanism gap: nothing checks that a file claiming to be a port has a header and a notices entry. A small test that greps Core/Stdlib for "port of CPython" / "ported from CPython" and requires a matching entry would keep this from drifting.


Generated by Claude Code

Activity

  1. antonsynd commented on Nov 11, 2026

    @antonsynd
    OwnerAuthor

    From the independent review of #2605: two more files that are structural ports of CPython source but make no "port" claim in a comment, so the new guard (which keys on self-declared ports) cannot find them.

    File What it mirrors How verified
    src/Sharpy.Stdlib/Difflib/SequenceMatcher.cs:57-160, :328 difflib.py __chain_b (b2j, bpopular, autojunk at n >= 200, ntest = n//100 + 1), find_longest_match (j2len/newj2len, the four junk-extension loops), fullbcount/avail read against the installed difflib.py
    src/Sharpy.Stdlib/Fractions/Fraction.cs:194-236 LimitDenominator fractions.py continued-fraction loop, same variable names (p0,q0,p1,q1,a,q2,k, bound1/bound2) and error message read against the installed fractions.py

    Not checked: Difflib/Differ.cs, Difflib/DifflibFunctions.cs, and the rest of Stdlib module by module. The guard's limit is structural: an audit by reading each Stdlib module against its CPython counterpart is the only way to find ports that do not announce themselves. #2605 keeps the notices intro saying the list is not exhaustive.

    Also noted: the notices file reproduces CPython's whole LICENSE.txt stack, which SPDX names Python-2.0; the package metadata uses PSF-2.0 (the PSF-era licence that covers post-2001 code). Both are real SPDX ids; which to declare is the owner's call.


    Generated by Claude Code

  2. added
    reach:probeNeeds an escaped spelling, a wrong-annotation probe or a python3 message diff
    on Nov 11, 2026
  3. added 2 commits that reference this issue on Nov 20, 2026
  4. antonsynd commented on Nov 20, 2026

    @antonsynd
    OwnerAuthor

    Closed — implemented in #2777 (merged into dev as 8adf932aa). Verified on dev:

    • R-NJ (a), the audit. Every Stdlib module with a CPython 3.15 namesake (55 of them) was read against its CPython source. 11 modules and 7 Core files are ports. Each port file now carries the PSF header lines and a numbered THIRD-PARTY-NOTICES.txt entry, and the "not yet exhaustive" sentence is gone.
    • This issue's rows:
      • Fraction.Format.cs, PyFormat.cs, PyFormatSpec.cs and Barrier.cs are headed and listed.
      • Str.cs and ThreadRegistry.cs are behaviour only, with neither.
      • The comment's rows (Difflib/SequenceMatcher.cs, Fraction.cs LimitDenominator) are headed and listed.
    • R-NO. Core, Stdlib and the sharpyc tool declare (Apache-2.0 OR MIT) AND Python-2.0.
    • Mechanism gap. build_tools/tests/test_third_party_notices.py's STDLIB_CENSUS maps every namesake module to port with its exact headed files, or to behaviour. A lost or extra header, or a new namesake module, is red; this was mutation-tested in build: complete the CPython notices (#2602 audit) #2777. test_third_party_notices.py and test_package_licenses.py give 62 passed at 8adf932aa.

    Not part of R-NJ and left as it is: decision 3, src/Sharpy.Stdlib.Tests/Spy/cpython/NOTICE's "2001-2024" years, which the body calls harmless. The review's follow-ups (docstrings adapted from CPython, the per-module packages, and Unicode and PyYAML credits) are in a lane on the owner's word (2026-11-20).


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lane:toolingDocs, formatter, LSP, build tools, tests, CIreach:probeNeeds an escaped spelling, a wrong-annotation probe or a python3 message diff

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions