Tribler / tribler

Privacy enhanced BitTorrent client with P2P content discovery
https://www.tribler.org
GNU General Public License v3.0
4.86k stars 451 forks source link

Illegal character in `create_dconfig_from_params` #8239

Closed hyui3434 closed 3 weeks ago

hyui3434 commented 3 weeks ago

Hi! I was using Tribler and THIS happened! :cry:

Traceback (most recent call last):
  File "D:\a\tribler\tribler\src\tribler\core\restapi\rest_manager.py", line 107, in error_middleware
  File "D:\a\tribler\tribler\src\tribler\core\restapi\rest_manager.py", line 162, in required_components_middleware
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\aiohttp\web_middlewares.py", line 117, in impl
  File "D:\a\tribler\tribler\src\tribler\core\libtorrent\restapi\downloads_endpoint.py", line 428, in add_download
  File "D:\a\tribler\tribler\src\tribler\core\libtorrent\restapi\downloads_endpoint.py", line 106, in create_dconfig_from_params
  File "D:\a\tribler\tribler\src\tribler\core\libtorrent\download_manager\download_config.py", line 132, in from_defaults
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\configobj\__init__.py", line 2108, in write
UnicodeEncodeError: 'ascii' codec can't encode character '\u044f' in position 20: ordinal not in range(128)
qstokkink commented 3 weeks ago

Thanks for the report. I can reproduce this.

Reproduction

  1. Create a new directory with Cyrillic characters. I used the directory ыц я бое! хыюи щертыфор щертыфор.
  2. Set the TSTATEDIR environment variable to that new directory.
  3. Launch Tribler and start a download.

Effects

When clicking a download, there is a vague error:

screenshot

The first error appears in the error reporter:

Traceback (most recent call last):
  File "\tribler\src\tribler\core\restapi\rest_manager.py", line 107, in error_middleware
    response = await handler(request)
  File "\tribler\src\tribler\core\restapi\rest_manager.py", line 162, in required_components_middleware
    return await handler(request)
  File "\tribler\venv\lib\site-packages\aiohttp\web_middlewares.py", line 114, in impl
    return await handler(request)
  File "\tribler\src\tribler\core\libtorrent\restapi\torrentinfo_endpoint.py", line 202, in get_torrent_info
    metainfo = await self.download_manager.get_metainfo(infohash, timeout=60, hops=i_hops, url=uri)
  File "\tribler\src\tribler\core\libtorrent\download_manager\download_manager.py", line 551, in get_metainfo
    dcfg = DownloadConfig.from_defaults(self.config)
  File "\tribler\src\tribler\core\libtorrent\download_manager\download_config.py", line 132, in from_defaults
    defaults.write(spec_file)
  File "\tribler\venv\lib\site-packages\configobj\__init__.py", line 2117, in write
    output_bytes = output.encode(self.encoding or
UnicodeEncodeError: 'ascii' codec can't encode characters in position 35-36: ordinal not in range(128)

If you click "Download" anyway, you get the second error of OP:

Traceback (most recent call last):
  File "\tribler\src\tribler\core\restapi\rest_manager.py", line 107, in error_middleware
    response = await handler(request)
  File "\tribler\src\tribler\core\restapi\rest_manager.py", line 162, in required_components_middleware
    return await handler(request)
  File "\tribler\venv\lib\site-packages\aiohttp\web_middlewares.py", line 114, in impl
    return await handler(request)
  File "\tribler\src\tribler\core\libtorrent\restapi\downloads_endpoint.py", line 428, in add_download
    download_config, error = self.create_dconfig_from_params(params)
  File "\tribler\src\tribler\core\libtorrent\restapi\downloads_endpoint.py", line 106, in create_dconfig_from_params
    download_config = DownloadConfig.from_defaults(self.download_manager.config)
  File "\tribler\src\tribler\core\libtorrent\download_manager\download_config.py", line 132, in from_defaults
    defaults.write(spec_file)
  File "\tribler\venv\lib\site-packages\configobj\__init__.py", line 2117, in write
    output_bytes = output.encode(self.encoding or
UnicodeEncodeError: 'ascii' codec can't encode characters in position 35-36: ordinal not in range(128)
qstokkink commented 3 weeks ago

This should be fixed in the upcoming 8.0.4 release.