dmachard / python-creditagricole-particuliers

Client Python, à destination des particuliers, souhaitant récupérer ses opérations bancaires stockées par le Crédit Agricole.
https://pypi.org/project/creditagricole-particuliers/
MIT License
39 stars 13 forks source link

UnboundLocalError: local variable 'url' referenced before assignment #14

Closed fbuloup closed 1 year ago

fbuloup commented 1 year ago

Bonjour,

dans la classe Logout :

import requests

class Logout:
    def __init__(self, session):
        """logout class"""
        self.session = session
        self.logout()

    def logout(self):
        """logout from remote"""
        url += "%s" % self.session.url
        url += "/%s/particulier.npc.logout.html?resource=" % self.session.regional_bank_url
        url += "/content/ca/cr866/npc/fr/particulier.html"
        r = requests.get(url=url,
                         verify=self.session.ssl_verify,
                     cookies=self.session.cookies)
        if r.status_code != 200:
            raise Exception( "[error] logout: %s - %s" % (r.status_code, r.text) )

La ligne 11 : url += "%s" % self.session.url provoque l'erreur local variable 'url' referenced before assignment

=> url = "%s" % self.session.url

Voici la trace complète :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/creditagricole_particuliers/logout.py", line 7, in __init__
    self.logout()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/creditagricole_particuliers/logout.py", line 11, in logout
    url += "%s" % self.session.url
UnboundLocalError: local variable 'url' referenced before assignment
dmachard commented 1 year ago

fixed