Skip to content

Commit 46ad1c9

Browse files
committed
DOC: Use correct constructor for unit subclasses.
Use `object.__new__` was raising for _everything_ that wasn't an `object` (aka, everything in the examples). It's necessary to use the actual class's `__new__`, which fixes the special initialization that was in the `try`.
1 parent 513c00b commit 46ad1c9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/units/basic_units.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def __new__(cls, value, unit):
127127
methods['__getitem__'] = cls._getitem
128128
subcls = type(f'TaggedValue_of_{value_class.__name__}',
129129
(cls, value_class), methods)
130-
return object.__new__(subcls)
130+
return value_class.__new__(subcls)
131131
except TypeError:
132132
return object.__new__(cls)
133133

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy