GeezerVison is showing github.com — Update libexpat to 2.6.4, make future updates easier · python/cpython@278df3c
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +1Lines changed: 1 addition & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +Upgrade libexpat to 2.6.4 |
Collapse file Copy file name to clipboardExpand all lines: Misc/sbom.spdx.json +11-11Lines changed: 11 additions & 11 deletions Collapse file Copy file name to clipboardExpand all lines: Modules/expat/expat.h +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -130,7 +130,9 @@ enum XML_Error { | 130 | 130 | /* Added in 2.3.0. */ | 131 | 131 | XML_ERROR_NO_BUFFER, | 132 | 132 | /* Added in 2.4.0. */ | 133 | | - XML_ERROR_AMPLIFICATION_LIMIT_BREACH | | 133 | + XML_ERROR_AMPLIFICATION_LIMIT_BREACH, | | 134 | + /* Added in 2.6.4. */ | | 135 | + XML_ERROR_NOT_STARTED, | 134 | 136 | }; | 135 | 137 |
| 136 | 138 | enum XML_Content_Type { | @@ -1066,7 +1068,7 @@ XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled); | 1066 | 1068 | */ | 1067 | 1069 | #define XML_MAJOR_VERSION 2 | 1068 | 1070 | #define XML_MINOR_VERSION 6 | 1069 | | -#define XML_MICRO_VERSION 3 | | 1071 | +#define XML_MICRO_VERSION 4 | 1070 | 1072 |
| 1071 | 1073 | #ifdef __cplusplus | 1072 | 1074 | } | |
Collapse file Copy file name to clipboardExpand all lines: Modules/expat/expat_external.h +4-5Lines changed: 4 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 40 | 40 | #ifndef Expat_External_INCLUDED | 41 | 41 | #define Expat_External_INCLUDED 1 | 42 | 42 |
| | 43 | +/* Namespace external symbols to allow multiple libexpat version to | | 44 | + co-exist. */ | | 45 | +#include "pyexpatns.h" | | 46 | + | 43 | 47 | /* External API definitions */ | 44 | 48 |
| 45 | 49 | /* Expat tries very hard to make the API boundary very specifically | | 64 | 68 | compiled with the cdecl calling convention as the default since | 65 | 69 | system headers may assume the cdecl convention. | 66 | 70 | */ | 67 | | - | 68 | | -/* Namespace external symbols to allow multiple libexpat version to | 69 | | - co-exist. */ | 70 | | -#include "pyexpatns.h" | 71 | | - | 72 | 71 | #ifndef XMLCALL | 73 | 72 | # if defined(_MSC_VER) | 74 | 73 | # define XMLCALL __cdecl | |
Collapse file Copy file name to clipboard +55Lines changed: 55 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +#!/usr/bin/env bash | | 2 | +# | | 3 | +# Use this script to update libexpat | | 4 | + | | 5 | +set -e | | 6 | +set -o pipefail | | 7 | + | | 8 | +if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then | | 9 | + echo "A bash version >= 4 required. Got: $BASH_VERSION" >&2 | | 10 | + exit 1 | | 11 | +fi | | 12 | + | | 13 | +# Update this when updating to a new version after verifying that the changes | | 14 | +# the update brings in are good. These values are used for verifying the SBOM, too. | | 15 | +expected_libexpat_tag="R_2_6_4" | | 16 | +expected_libexpat_version="2.6.4" | | 17 | + | | 18 | +expat_dir="$(realpath "$(dirname -- "${BASH_SOURCE[0]}")")" | | 19 | +cd ${expat_dir} | | 20 | + | | 21 | +# Step 1: download and copy files | | 22 | +curl --location "https://github.com/libexpat/libexpat/releases/download/${expected_libexpat_tag}/expat-${expected_libexpat_version}.tar.gz" > libexpat.tar.gz | | 23 | + | | 24 | +# Step 2: Pull files from the libexpat distribution | | 25 | +declare -a lib_files | | 26 | +lib_files=( | | 27 | + ascii.h | | 28 | + asciitab.h | | 29 | + expat.h | | 30 | + expat_external.h | | 31 | + iasciitab.h | | 32 | + internal.h | | 33 | + latin1tab.h | | 34 | + nametab.h | | 35 | + siphash.h | | 36 | + utf8tab.h | | 37 | + winconfig.h | | 38 | + xmlparse.c | | 39 | + xmlrole.c | | 40 | + xmlrole.h | | 41 | + xmltok.c | | 42 | + xmltok.h | | 43 | + xmltok_impl.c | | 44 | + xmltok_impl.h | | 45 | + xmltok_ns.c | | 46 | +) | | 47 | +for f in "${lib_files[@]}"; do | | 48 | + tar xzvf libexpat.tar.gz "expat-${expected_libexpat_version}/lib/${f}" --strip-components 2 | | 49 | +done | | 50 | +rm libexpat.tar.gz | | 51 | + | | 52 | +# Step 3: Add the namespacing include to expat_external.h | | 53 | +sed -i 's/#define Expat_External_INCLUDED 1/&\n\n\/* Namespace external symbols to allow multiple libexpat version to\n co-exist. \*\/\n#include "pyexpatns.h"/' expat_external.h | | 54 | + | | 55 | +echo "Updated; verify all is okay using git diff and git status." |
Collapse file Copy file name to clipboardExpand all lines: Modules/expat/xmlparse.c +14-4Lines changed: 14 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -/* ba4cdf9bdb534f355a9def4c9e25d20ee8e72f95b0a4d930be52e563f5080196 (2.6.3+) | | 1 | +/* c5625880f4bf417c1463deee4eb92d86ff413f802048621c57e25fe483eb59e4 (2.6.4+) | 2 | 2 | __ __ _ | 3 | 3 | ___\ \/ /_ __ __ _| |_ | 4 | 4 | / _ \\ /| '_ \ / _` | __| | | 40 | 40 | | 41 | 41 | | 42 | 42 | | | 43 | + | 43 | 44 | Licensed under the MIT license: | 44 | 45 |
| 45 | 46 | Permission is hereby granted, free of charge, to any person obtaining | @@ -2234,6 +2235,9 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable) { | 2234 | 2235 | if (parser == NULL) | 2235 | 2236 | return XML_STATUS_ERROR; | 2236 | 2237 | switch (parser->m_parsingStatus.parsing) { | | 2238 | + case XML_INITIALIZED: | | 2239 | + parser->m_errorCode = XML_ERROR_NOT_STARTED; | | 2240 | + return XML_STATUS_ERROR; | 2237 | 2241 | case XML_SUSPENDED: | 2238 | 2242 | if (resumable) { | 2239 | 2243 | parser->m_errorCode = XML_ERROR_SUSPENDED; | @@ -2244,7 +2248,7 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable) { | 2244 | 2248 | case XML_FINISHED: | 2245 | 2249 | parser->m_errorCode = XML_ERROR_FINISHED; | 2246 | 2250 | return XML_STATUS_ERROR; | 2247 | | - default: | | 2251 | + case XML_PARSING: | 2248 | 2252 | if (resumable) { | 2249 | 2253 | #ifdef XML_DTD | 2250 | 2254 | if (parser->m_isParamEntity) { | @@ -2255,6 +2259,9 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable) { | 2255 | 2259 | parser->m_parsingStatus.parsing = XML_SUSPENDED; | 2256 | 2260 | } else | 2257 | 2261 | parser->m_parsingStatus.parsing = XML_FINISHED; | | 2262 | + break; | | 2263 | + default: | | 2264 | + assert(0); | 2258 | 2265 | } | 2259 | 2266 | return XML_STATUS_OK; | 2260 | 2267 | } | @@ -2519,6 +2526,9 @@ XML_ErrorString(enum XML_Error code) { | 2519 | 2526 | case XML_ERROR_AMPLIFICATION_LIMIT_BREACH: | 2520 | 2527 | return XML_L( | 2521 | 2528 | "limit on input amplification factor (from DTD and entities) breached"); | | 2529 | + /* Added in 2.6.4. */ | | 2530 | + case XML_ERROR_NOT_STARTED: | | 2531 | + return XML_L("parser not started"); | 2522 | 2532 | } | 2523 | 2533 | return NULL; | 2524 | 2534 | } | @@ -7856,7 +7866,7 @@ accountingReportDiff(XML_Parser rootParser, | 7856 | 7866 | assert(! rootParser->m_parentParser); | 7857 | 7867 |
| 7858 | 7868 | fprintf(stderr, | 7859 | | - " (+" EXPAT_FMT_PTRDIFF_T("6") " bytes %s|%d, xmlparse.c:%d) %*s\"", | | 7869 | + " (+" EXPAT_FMT_PTRDIFF_T("6") " bytes %s|%u, xmlparse.c:%d) %*s\"", | 7860 | 7870 | bytesMore, (account == XML_ACCOUNT_DIRECT) ? "DIR" : "EXP", | 7861 | 7871 | levelsAwayFromRootParser, source_line, 10, ""); | 7862 | 7872 |
| @@ -7969,7 +7979,7 @@ entityTrackingReportStats(XML_Parser rootParser, ENTITY *entity, | 7969 | 7979 |
| 7970 | 7980 | fprintf( | 7971 | 7981 | stderr, | 7972 | | - "expat: Entities(%p): Count %9d, depth %2d/%2d %*s%s%s; %s length %d (xmlparse.c:%d)\n", | | 7982 | + "expat: Entities(%p): Count %9u, depth %2u/%2u %*s%s%s; %s length %d (xmlparse.c:%d)\n", | 7973 | 7983 | (void *)rootParser, rootParser->m_entity_stats.countEverOpened, | 7974 | 7984 | rootParser->m_entity_stats.currentDepth, | 7975 | 7985 | rootParser->m_entity_stats.maximumDepthSeen, | |
Collapse file Copy file name to clipboardExpand all lines: Tools/build/generate_sbom.py +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -59,6 +59,8 @@ class PackageFiles(typing.NamedTuple): | 59 | 59 | include=["Modules/expat/**"], | 60 | 60 | exclude=[ | 61 | 61 | "Modules/expat/expat_config.h", | | 62 | + "Modules/expat/pyexpatns.h", | | 63 | + "Modules/_hacl/refresh.sh", | 62 | 64 | ] | 63 | 65 | ), | 64 | 66 | "macholib": PackageFiles( | @@ -218,6 +220,20 @@ def check_sbom_packages(sbom_data: dict[str, typing.Any]) -> None: | 218 | 220 | "HACL* SBOM version doesn't match value in 'Modules/_hacl/refresh.sh'" | 219 | 221 | ) | 220 | 222 |
| | 223 | + # libexpat specifies its expected rev in a refresh script. | | 224 | + if package["name"] == "libexpat": | | 225 | + libexpat_refresh_sh = (CPYTHON_ROOT_DIR / "Modules/expat/refresh.sh").read_text() | | 226 | + libexpat_expected_version_match = re.search( | | 227 | + r"expected_libexpat_version=\"([0-9]+\.[0-9]+\.[0-9]+)\"", | | 228 | + libexpat_refresh_sh | | 229 | + ) | | 230 | + libexpat_expected_version = libexpat_expected_version_match and libexpat_expected_version.group(1) | | 231 | + | | 232 | + error_if( | | 233 | + libexpat_expected_version != version, | | 234 | + "libexpat SBOM version doesn't match value in 'Modules/expat/refresh.sh'" | | 235 | + ) | | 236 | + | 221 | 237 | # License must be on the approved list for SPDX. | 222 | 238 | license_concluded = package["licenseConcluded"] | 223 | 239 | error_if( | |
|