Message368502
Hi Jason,
to achieve better backwards compatibility, it's probably better to use
the approach taken for CodeInfo in the codecs.py module:
class CodecInfo(tuple):
"""Codec details when looking up the codec registry"""
def __new__(cls, encode, decode, streamreader=None, streamwriter=None,
incrementalencoder=None, incrementaldecoder=None, name=None,
*, _is_text_encoding=None):
self = tuple.__new__(cls, (encode, decode, streamreader,
streamwriter))
self.name = name
self.encode = encode
self.decode = decode
self.incrementalencoder = incrementalencoder
self.incrementaldecoder = incrementaldecoder
self.streamwriter = streamwriter
self.streamreader = streamreader
if _is_text_encoding is not None:
self._is_text_encoding = _is_text_encoding
return self
def __repr__(self):
return "<%s.%s object for encoding %s at %#x>" % \
(self.__class__.__module__, self.__class__.__qualname__,
self.name, id(self))
This used to be a 4 entry tuple and was extended to hold additional
fields. To the outside, it still looks like a 4-tuple in all aspects,
but attribute access permits accessing the additional fields.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Experts (#1, May 09 2020)
>>> Python Projects, Coaching and Support ... https://www.egenix.com/
>>> Python Product Development ... https://consulting.egenix.com/
________________________________________________________________________
::: We implement business ideas - efficiently in both time and costs :::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
https://www.egenix.com/company/contact/
https://www.malemburg.com/ |
|
| Date |
User |
Action |
Args |
| 2020-05-09 08:09:43 | lemburg | set | recipients:
+ lemburg, jaraco, tucked |
| 2020-05-09 08:09:43 | lemburg | link | issue40570 messages |
| 2020-05-09 08:09:43 | lemburg | create | |
|