Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hardwareprofile: drop ancient python2 compatibility libraries: "future" and "simplejson" #838

Merged
merged 2 commits into from
Jan 8, 2024

Commits on Jan 8, 2024

  1. hardwareprofile: remove external dependency on simplejson

    This uses the requests module and converts requests responses to json
    using requests' own `.json()` method on responses. For incomprehensible
    reasons, requests has spent about a decade using either simplejson or
    the standard library's json module more or less at will, and returning
    either one or the other exception types. They don't know why they use
    simplejson, we don't know why they use simplejson. In requests 3 (which
    will be released in the Year Of The Linux Desktop or when pigs fly,
    whichever one comes later) simplejson is dropped entirely.
    
    There are innumerable issues discussing the problem on the requests
    bugtracker, with the general consensus being that it's better to
    randomly return either one of two different libraries and two different
    library return types in errors -- because it was historically done that
    way and people might be depending on it. ??????
    
    Bugs:
    
    psf/requests#710
    psf/requests#2516
    psf/requests#3052
    psf/requests#4169
    psf/requests#4842
    psf/requests#5794
    psf/requests#6084
    
    The awkward workaround is to guarantee that requests' silent behavior of
    using simplejson *if it is installed* is forcibly triggered by forcibly
    depending on simplejson, and then catching the simplejson exception.
    
    The better solution here is pretty simple: do not rely on the requests
    module's automatic json conversion, this is as simple as using the
    already-imported json module and calling json.loads() on the retrieved
    content.
    
    Fixes: 1df343e
    Reimplements: bb154a8
    eli-schwartz committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    6348dc0 View commit details
    Browse the repository at this point in the history
  2. hardwareprofile: remove ancient "future" compatibility library for py…

    …thon2
    
    Ironically, for a package that was intended to provide portability
    between python2 and python3, it is broken with python 3.12. A better
    library to use in all cases is "six".
    
    However, mythtv requires python 3.8 for a while now. Using
    "future.standard_library" is a no-op other than costing a pointless
    import and being troublesome to actually install.
    
    The hacky copy of six.with_metaclass included in "future" is rewritten
    to use the pure python3 form of a metaclass.
    eli-schwartz committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    4a1ea33 View commit details
    Browse the repository at this point in the history