[New-bugs-announce] [issue43085] Loosening | and |= operator type checking restriction

Siyavash report at bugs.python.org
Sun Jan 31 11:14:39 EST 2021

New submission from Siyavash <Varzeghani.Siyavash at gmail.com>:

| and |= operators work only if the operands are of 'dict' type. This means that they can't be used with some of the user defined mapping objects.

The case that especially caught my attention was 'SignalDict' type in decimal standard library. While 'SignalDict' has got an update method like 'dict', it can not be updated with |= operator. The following code results in a TypeError:

decimal.getcontext().traps |= {decimal.DivisionByZero:False}

components: Regular Expressions
messages: 386028
nosy: Siy_V, brandtbucher, ezio.melotti, mrabarnett, steven.daprano
priority: normal
severity: normal
status: open
title: Loosening | and |= operator type checking restriction
type: enhancement
versions: Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list