tldr-pages/tldr-python-client

Running 'tldr -- language zh' in python 3.13.1 reports an error

autext opened this issue · 1 comments

i'm using python 3.13.1, and when I input tldr -- language zh, the console reports an error

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\softwares\Python313\Scripts\tldr.exe\__main__.py", line 7, in <module>
    sys.exit(cli())
             ~~~^^
  File "D:\softwares\Python313\Lib\site-packages\tldr.py", line 665, in cli
    main()
    ~~~~^^
  File "D:\softwares\Python313\Lib\site-packages\tldr.py", line 632, in main
    results = get_page_for_every_platform(
        command,
    ...<2 lines>...
        options.language
    )
  File "D:\softwares\Python313\Lib\site-packages\tldr.py", line 283, in get_page_for_every_platform
    get_page_for_platform(
    ~~~~~~~~~~~~~~~~~~~~~^
        command,
        ^^^^^^^^
    ...<2 lines>...
        language
        ^^^^^^^^
    ),
    ^
  File "D:\softwares\Python313\Lib\site-packages\tldr.py", line 169, in get_page_for_platform
    data = urlopen(
           ~~~~~~~^
        Request(page_url, headers=REQUEST_HEADERS),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        timeout=10,
        ^^^^^^^^^^^
        context=URLOPEN_CONTEXT
        ^^^^^^^^^^^^^^^^^^^^^^^
    ).read()
    ^
  File "D:\softwares\Python313\Lib\urllib\request.py", line 189, in urlopen
    return opener.open(url, data, timeout)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "D:\softwares\Python313\Lib\urllib\request.py", line 489, in open
    response = self._open(req, data)
  File "D:\softwares\Python313\Lib\urllib\request.py", line 506, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
                              '_open', req)
  File "D:\softwares\Python313\Lib\urllib\request.py", line 466, in _call_chain
    result = func(*args)
  File "D:\softwares\Python313\Lib\urllib\request.py", line 1367, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                        context=self._context)
                        ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\softwares\Python313\Lib\urllib\request.py", line 1323, in do_open
    r = h.getresponse()
  File "D:\softwares\Python313\Lib\http\client.py", line 1428, in getresponse
    response.begin()
    ~~~~~~~~~~~~~~^^
  File "D:\softwares\Python313\Lib\http\client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ~~~~~~~~~~~~~~~~~^^
  File "D:\softwares\Python313\Lib\http\client.py", line 292, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
               ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "D:\softwares\Python313\Lib\socket.py", line 719, in readinto
    return self._sock.recv_into(b)
           ~~~~~~~~~~~~~~~~~~~~^^^
  File "D:\softwares\Python313\Lib\ssl.py", line 1304, in recv_into
    return self.read(nbytes, buffer)
           ~~~~~~~~~^^^^^^^^^^^^^^^^
  File "D:\softwares\Python313\Lib\ssl.py", line 1138, in read
    return self._sslobj.read(len, buffer)
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
TimeoutError: The read operation timed out

how can i fix it

You should input tldr --language zh (without the space after --). Also, you need to tell tldr which page you would like to view. For example, if you want to view the chinese tldr page for the command tar, you should input tldr --language zh tar.