我一直在努力讓2.5模塊移植到3.0,主要是爲了我自己的教育,當我陷入困境時。類 「生成器」 作爲其初始化:有關3.0的「hashlib」模塊的問題
def __init__(self, **options):
self._verifyOptions(options)
self._options = options
self._initDigest()
self._initBuildNames()
self._methods = []
但在出現錯誤:
def _initDigest(self):
import os, sys, hashlib
digester = hashlib.md5()
digester.update(self._options.get('code'))
self._digest = digester.hexdigest()
它有它的回溯:
Traceback (most recent call last):
File "<pyshell#5>", line 5, in <module>
""", language="Cee")
File "C:\Python30\lib\site-packages\PyInline\__init__.py", line 31, in build
b = m.Builder(**args)
File "C:\Python30\lib\site-packages\PyInline\Cee.py", line 17, in __init__
self._initDigest()
File "C:\Python30\lib\site-packages\PyInline\Cee.py", line 27, in _initDigest
digester.update(self._options.get('code'))
TypeError: object supporting the buffer API required
我已經通過2to3運行它,但它並沒有採取它。據我所知,更新函數期望的參數是以字節/緩衝區的形式,但我已經嘗試了幾種不同的方法來轉換它,並沒有成功。
一如既往,任何援助將不勝感激。 :)
您已成功糾正此錯誤,並在此任務中進一步教育我。我祝賀並感謝你! – 2008-12-05 09:18:24