This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author acue
Recipients Quentin.Pradet, acue, deivid, martin.panter
Date 2018-11-28.06:53:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1543388010.85.0.788709270274.issue35334@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,
I am using the installation script *adafruit-pitft.sh* which tries to apply *urllib3* which itself tries to install nested dependencies,
here *evdev* from PyPI.

When the installation is offline - e.g. by internal mirror of debian/raspbian - PyPI is not accessible. The code fails than by an type error
exception:

> adafruit-pitft.sh # or pitft.sh 
> https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/master/adafruit-pitft.sh
>
> ...
> 
>   _stacktrace=sys.exc_info()[2])
>  File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3 none-any.whl/urllib3/util/retry.py", line 228, in increment
>
>    total -= 1
>
> TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

For the current distribution(based on debian-9.6.0/stretch):

>  File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment
>
>    total -= 1
>
> TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

See also: https://stackoverflow.com/questions/37495375/python-pip-install-throws-typeerror-unsupported-operand-types-for-retry


The following - dirty *:) - patch enables a sounding error trace:

    # File: retry.py - in *def increment(self, ..* about line 315
    # original: total = self.total
    
    # patch: quick-and-dirty-fix
    # START:
    if isinstance(self.total, Retry):
        self.total = self.total.total
    
    if type(self.total) is not int:
        self.total = 2 # default is 10
    # END:
    
    # continue with original:
    total = self.total

    if total is not None:
        total -= 1
    
    connect = self.connect
    read = self.read
    redirect = self.redirect
    cause = 'unknown'
    status = None
    redirect_location = None
    
    if error and self._is_connection_error(error):
        # Connect retry?
        if connect is False:
            raise six.reraise(type(error), error, _stacktrace)
        elif connect is not None:
            connect -= 1


The sounding output with the temporary patch is(twice...):

> Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(&lt;requests.packages.urllib3.connection.VerifiedHTTPSConnection object at/
>
>  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 
'ConnectTimeoutError(&lt;requests.packages.urllib3.connection.VerifiedHTTPSConnection object at/
>
>  Could not find a version that satisfies the requirement evdev (from versions: )
>
> No matching distribution found for evdev
>
> WARNING : Pip failed to install software!

In this case I did not thoroughly analysed the actual error source, thus did a quick and dirty patch only.

My proposal is to add the inplace operator to the class *Reply* with the default assignment in case of an type error and display an error message.
This is still not really the correct solution, but resolves a lot of confusion by required interpretation of the exception.

Arno-Can Uestuensoez
History
Date User Action Args
2018-11-28 06:53:31acuesetrecipients: + acue, martin.panter, Quentin.Pradet, deivid
2018-11-28 06:53:30acuesetmessageid: <1543388010.85.0.788709270274.issue35334@psf.upfronthosting.co.za>
2018-11-28 06:53:30acuelinkissue35334 messages
2018-11-28 06:53:28acuecreate