<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Warnings on Nalar</title>
    <link>https://nalar.dev/tags/warnings/</link>
    <description>Recent content in Warnings on Nalar</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 09 Sep 2026 00:00:00 +0700</lastBuildDate>
    <atom:link href="https://nalar.dev/tags/warnings/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Make Warning Tests Concurrency-Safe with Context-Aware Warnings</title>
      <link>https://nalar.dev/make-warning-tests-concurrency-safe-with-context-aware-warnings/</link>
      <pubDate>Wed, 09 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/make-warning-tests-concurrency-safe-with-context-aware-warnings/</guid>
      <description>&lt;p&gt;Python&amp;rsquo;s &lt;code&gt;warnings.catch_warnings()&lt;/code&gt; is convenient in tests, compatibility shims, and small diagnostic scopes. It lets code temporarily change warning filters and then restore the previous state.&lt;/p&gt;&#xA;&lt;p&gt;That model becomes harder to reason about when several threads or asynchronous tasks use it at the same time. Historically, &lt;code&gt;catch_warnings()&lt;/code&gt; manipulated process-global state in the &lt;code&gt;warnings&lt;/code&gt; module. Two overlapping contexts could therefore interfere with each other.&lt;/p&gt;&#xA;&lt;p&gt;Python 3.14 adds an opt-in context-aware mode that changes this behavior. When &lt;code&gt;sys.flags.context_aware_warnings&lt;/code&gt; is true, &lt;code&gt;catch_warnings()&lt;/code&gt; stores its filtering state in a context variable instead of mutating the same global warning state for every concurrent execution path.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
