[libc-commits] [libc] Replace python 3.9 dict | operator to support older python versions (PR #236599)
via libc-commits
libc-commits at lists.llvm.org
Wed Oct 28 16:46:04 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Manuel Drehwald (ZuseZ4)
<details>
<summary>Changes</summary>
I'm experimenting with providing libc-for-gpu as part of Rust's `std::offload`, to make debugging nicer and experiment with how much of std we could support. https://github.com/rust-lang/rust/pull/161565/changes
We noticed we need to add pyyaml for libc ( or rather hdrgen), which we're fine with adding. There are 3 more lines not supported by our CI version of Python (3.6). The used dict features were [introduced](https://docs.python.org/3/whatsnew/3.9.html#dictionary-merge-update-operators) in Python 3.9. Given how small the diff is, I hope no one minds this change to support older Pythons for a bit longer.
LLM disclosure: I asked an llm to look at features not supported by python 3.6, and suggest identical alternatives that work with 3.6
---
Full diff: https://github.com/llvm/llvm-project/pull/236599.diff
1 Files Affected:
- (modified) libc/utils/hdrgen/hdrgen/header.py (+3-3)
``````````diff
diff --git a/libc/utils/hdrgen/hdrgen/header.py b/libc/utils/hdrgen/hdrgen/header.py
index db6a064aaf7f39..d16f9b01e7f256 100644
--- a/libc/utils/hdrgen/hdrgen/header.py
+++ b/libc/utils/hdrgen/hdrgen/header.py
@@ -139,7 +139,7 @@ def merge(self, other):
self.enumerations = sorted(set(self.enumerations) | set(other.enumerations))
self.objects = sorted(set(self.objects) | set(other.objects))
self.functions = sorted(set(self.functions) | set(other.functions))
- self.extra_standards |= other.extra_standards
+ self.extra_standards = {**self.extra_standards, **other.extra_standards}
self.public_includes = sorted(
set(self.public_includes) | set(other.public_includes)
)
@@ -174,7 +174,7 @@ def all_standards(self):
for item in collection:
if item.standards:
standards.update(item.standards)
- descriptions = LIBRARY_DESCRIPTIONS | self.extra_standards
+ descriptions = {**LIBRARY_DESCRIPTIONS, **self.extra_standards}
for standard in standards:
if standard not in descriptions:
# Provide a helpful error message with acceptable values.
@@ -216,7 +216,7 @@ def header_guard(self, proxy=False):
def library_description(self):
# This also validates all standards.
standards = self.all_standards()
- descriptions = LIBRARY_DESCRIPTIONS | self.extra_standards
+ descriptions = {**LIBRARY_DESCRIPTIONS, **self.extra_standards}
# If the header itself is in standard C, just call it that.
if "stdc" in self.standards:
return descriptions["stdc"]
``````````
</details>
https://github.com/llvm/llvm-project/pull/236599
More information about the libc-commits
mailing list