[
https://issues.apache.org/jira/browse/CASSPYTHON-27?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Brad Schoening updated CASSPYTHON-27:
-------------------------------------
Component/s: Core
Status: Open (was: Triage Needed)
> Replace outdated Python 2.x support
> -----------------------------------
>
> Key: CASSPYTHON-27
> URL: https://issues.apache.org/jira/browse/CASSPYTHON-27
> Project: Apache Cassandra Python driver
> Issue Type: Improvement
> Components: Core
> Reporter: Brad Schoening
> Priority: Low
>
> Replace outdated code like this which was supporting pre-v3 support
> *1.* cluster.py: Python standard library until (2.7.9, 3.2). To enable
> this mechanism in earlier versions, patch ``ssl.match_hostname``
> *2.* util.py
> a. similar to collections.namedtuple, reproduced here because Python 2.6 did
> not have the rename logic
> def _positional_rename_invalid_identifiers(field_names):
> b. The whole *hand-rolled {{WeakSet}} class* + its {{_IterationGuard}} helper
> (~150 lines) — this is the big one.
> This is a line-for-line reimplementation of CPython's own
> {{{}weakref.WeakSet{}}}, right down to matching internal names
> ({{{}_pending_removals{}}}, {{{}_iterating{}}}, {{{}_commit_removals{}}},
> {{{}_IterationGuard{}}}). {{weakref.WeakSet}} has existed in the standard
> library since Python 2.7 / 3.0. There's no reason to carry a private copy on
> 3.10+; it can be deleted entirely and replaced with:
> This is almost certainly legacy from a very old Python 2.5/2.6-era codebase
> where {{WeakSet}} wasn't yet in stdlib.
> *c. {{from _weakref import ref}}*
> Importing the private C-accelerated {{_weakref}} module directly rather than
> the public {{weakref}} module. {{weakref.ref}} is exactly this, just
> re-exported — this buys nothing on modern Python and should just be {{{}from
> weakref import ref{}}}.
> *d. Explicit {{object}} inheritance* — {{{}class
> _IterationGuard(object):{}}}, {{{}class WeakSet(object):{}}}, {{{}class
> SortedSet(object):{}}}, etc.
> This is the Python 2 "new-style class" idiom. Since Python 3 has no old-style
> classes, {{(object)}} is pure dead boilerplate now — harmless, but obsolete
> style that a 3.10+-only codebase wouldn't write.
> *e. {{super(OrderedMapSerializedKey, self).__init__()}}*
> The two-argument {{super()}} form is the Python 2/3-compatible spelling. On
> 3.10+ this is just {{{}super().__init__(){}}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]