在我维护的(传统)代码中,人们使用的是windows错误。 可以用操作系统错误替换所有出现的情况,但很遗憾,正在使用winerror属性。 令人高兴的是,只有三种情况: 123:try:
mtime=int(OS.path.getmtime ) self._s ) )
except WindowsError,werr:
if werr.winerror!=123: raise
de print (u ' unabletodeterminemodifiedtimeof % s-probablyaunicodeerror ' % self._ s ) )
第740页:
^{pr2}$
和32:try:
patch name.un temp (# calls shutil.move ) (and os.remove ) )。
except WindowsError,werr:
while werr.winerror==32 andself._ retry (patch name.temp.s,
patchname.s(:
try:
patchName.untemp (
except WindowsError,werr:
连续
布雷克
else:
雷西
如何将这些代码翻译成操作系统错误? 在
我在Python2.7上,所以不能使用appendix-a-survey-of-common-errnos ' rel=' nofollow ' pep-3151引入的良好异常
以下是将winerror映射到errno模块的discussion