Skip to content

AttributeError: 'tuple' object has no attribute 'url' #2432

Closed

Description

@FuckingToasters
        [] Proxy Type (http/https/socks5) | Enter nothing to use without Proxy: http
        Country:  is not supported.!
Exception in thread Thread-1 (verify):
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Administrator\Desktop\discordphoneverify\new version\main.py", line 131, in verify
    checktoken()
  File "C:\Users\Administrator\Desktop\discordphoneverify\new version\main.py", line 120, in checktoken
    with httpx.Client(headers=HEADERS, timeout=timeout, proxies=proxyauth if proxytype != "" else None) as client:
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx_client.py", line 683, in init
    self._mounts: typing.Dict[URLPattern, typing.Optional[BaseTransport]] = {
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx_client.py", line 686, in <dictcomp>
    else self._init_proxy_transport(
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx_client.py", line 740, in _init_proxy_transport
    return HTTPTransport(
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx_transports\default.py", line 140, in init
    elif proxy.url.scheme in ("http", "https"):
AttributeError: 'tuple' object has no attribute 'url'
```

Activity

  1. lovelydinosaur commented on Nov 8, 2022

    @lovelydinosaur
    Member

    You would see this exception if you specified the proxies=... argument as a tuple, rather than as a dictionary.

    # OK
    proxies = {
        "http://": "http://localhost:8030",
        "https://": "http://localhost:8031",
    }
    httpx.get('https://www.example.com/', proxies=proxies)
    
    # Oops
    proxies = (
        "http://localhost:8030",
        "http://localhost:8031",
    )
    httpx.get('https://www.example.com/', proxies=proxies)

    I'm going to close this off for now since strictly speaking it's a misusage of the package, rather than a bug.
    But it is a useful indicator. A UX improvement here would be to raise a TypeError instead.

    Related #2404, #2406.

    Useful resource here: HTTPX Proxy docs

  2. FuckingToasters commented on Nov 12, 2022

    @FuckingToasters
    Author

    You would see this exception if you specified the proxies=... argument as a tuple, rather than as a dictionary.

    # OK
    proxies = {
        "http://": "http://localhost:8030",
        "https://": "http://localhost:8031",
    }
    httpx.get('https://www.example.com/', proxies=proxies)
    
    # Oops
    proxies = (
        "http://localhost:8030",
        "http://localhost:8031",
    )
    httpx.get('https://www.example.com/', proxies=proxies)

    I'm going to close this off for now since strictly speaking it's a misusage of the package, rather than a bug. But it is a useful indicator. A UX improvement here would be to raise a TypeError instead.

    Related #2404, #2406.

    Useful resource here: HTTPX Proxy docs

    The thing is that i don't have made a tuple, it's a normal dict:

    import pystyle
    class loadproxyclass:
        def loadproxy(self, proxytype):
            with open("files/proxies.txt", "r") as proxy_file:
                proxies = proxy_file.read().splitlines()
                proxy_split = "None"
                proxyauth, hostname, port, username, password = None, None, None, None, None
    
                for proxy in proxies: proxy_split = proxy.split(":")
                try:
                    hostname, port, username, password = proxy_split[0], proxy_split[1], proxy_split[2], proxy_split[3]
                    proxy_formatted = f"{proxytype}://{username}:{password}@{hostname}:{port}"
                    if proxytype != "": proxyauth = {"all://": proxy_formatted}
                    else: proxyauth = {"all://": None}
    
                except IndexError:
                    try:
                        hostname, port, username, password = proxy_split[0], proxy_split[1], None, None
                        proxy_formatted = f"{proxytype}://{hostname}:{port}"
                        if proxytype != "": proxyauth = {"all://": proxy_formatted}
                        else: proxyauth = {"all://": None}
    
                    except IndexError:
                        pystyle.Write.Print("\t[*] Proxies inside files/proxies.txt are not formatted correctly (IP:PORT or IP:PORT:USER:PASS)!\n", pystyle.Colors.yellow, interval=0)
                        proxyauth = {"all://": None}
                
                return proxyauth, hostname, port, username, password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions