![由于 UnicodeDecodeError 导致 Debian 软件包快速损坏](https://linux22.com/image/820040/%E7%94%B1%E4%BA%8E%20UnicodeDecodeError%20%E5%AF%BC%E8%87%B4%20Debian%20%E8%BD%AF%E4%BB%B6%E5%8C%85%E5%BF%AB%E9%80%9F%E6%8D%9F%E5%9D%8F.png)
我使用 Quickly 创建了一个测试应用程序。当我使用时quickly package
,我收到此警告:
Ubuntu packaging created in debian/
...............................................................................................................................................................................
Befehl gab einige WARNUNGEN zurück:
----------------------------------
** (setup.py:3685): WARNING **: Fehler beim Senden der Anmeldedaten: Fehler beim Senden der Nachricht: Die Operation ist nicht erlaubt
----------------------------------
如果我尝试安装 .deb,我会收到此警告:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/aptdaemon/worker.py", line 1041, in _simulate
trans.unauthenticated = self.__simulate(trans)
File "/usr/lib/python2.7/dist-packages/aptdaemon/worker.py", line 1098, in __simulate
deb = self.install_file(trans, simulate=True, **trans.kwargs)
File "/usr/lib/python2.7/dist-packages/aptdaemon/worker.py", line 591, in install_file
deb = self._check_deb_file(path, force, trans.uid)
File "/usr/lib/python2.7/dist-packages/aptdaemon/worker.py", line 1227, in _check_deb_file
"\n%s" % (path, stdout))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 48: ordinal not in range(128)
运行packagedebuild
给出quickly
了以下输出:http://pastebin.ubuntu.com/1052328/
答案1
通常,当您看到这样的错误时,这意味着无法显示非英文字符 - 当您让人翻译您的应用程序并且需要显示非英文字符时,这是一个常见的问题。
我通常的解决方法是将字符串转换为 UTF-8 后再显示。例如:
str = widget.get_text(label).decode("UTF-8")
(注意:我没有测试过此代码,但通常添加decode()
到字符串中是可行的)。