91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 5KB
    文件類型: .py
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-01
  • 語言: Python
  • 標簽: fcantl.py??

資源簡介

python在window上使用python-3.6.5-amd64.exe直接安裝時會缺少fcntl.py文件,影響python使用。但是如果使用python-3.6.5-amd64-webinstall.exe安裝就不會缺少該文件。解決辦法:可以下載該文件放到python安裝路徑下的lib包內(nèi),或者卸載python,用python-3.6.5-amd64-webinstall.exe安裝即可。

資源截圖

代碼片段和文件信息

“““Test?program?for?the?fcntl?C?module.
“““
import?platform
import?os
import?struct
import?sys
import?unittest
from?test.support?import?(verbose?TESTFN?unlink?run_unittest?import_module
??????????????????????????cpython_only)

#?Skip?test?if?no?fcntl?module.
fcntl?=?import_module(‘fcntl‘)


#?TODO?-?Write?tests?for?flock()?and?lockf().

def?get_lockdata():
????try:
????????os.O_LARGEFILE
????except?AttributeError:
????????start_len?=?“l(fā)l“
????else:
????????start_len?=?“qq“

????if?(sys.platform.startswith((‘netbsd‘?‘freebsd‘?‘openbsd‘?‘bsdos‘))
????????or?sys.platform?==?‘darwin‘):
????????if?struct.calcsize(‘l‘)?==?8:
????????????off_t?=?‘l‘
????????????pid_t?=?‘i‘
????????else:
????????????off_t?=?‘lxxxx‘
????????????pid_t?=?‘l‘
????????lockdata?=?struct.pack(off_t?+?off_t?+?pid_t?+?‘hh‘?0?0?0
???????????????????????????????fcntl.F_WRLCK?0)
????elif?sys.platform.startswith(‘gnukfreebsd‘):
????????lockdata?=?struct.pack(‘qqihhi‘?0?0?0?fcntl.F_WRLCK?0?0)
????elif?sys.platform?in?[‘a(chǎn)ix3‘?‘a(chǎn)ix4‘?‘hp-uxB‘?‘unixware7‘]:
????????lockdata?=?struct.pack(‘hhlllii‘?fcntl.F_WRLCK?0?0?0?0?0?0)
????else:
????????lockdata?=?struct.pack(‘hh‘+start_len+‘hh‘?fcntl.F_WRLCK?0?0?0?0?0)
????if?lockdata:
????????if?verbose:
????????????print(‘struct.pack:?‘?repr(lockdata))
????return?lockdata

lockdata?=?get_lockdata()

class?BadFile:
????def?__init__(self?fn):
????????self.fn?=?fn
????def?fileno(self):
????????return?self.fn

class?TestFcntl(unittest.TestCase):

????def?setUp(self):
????????self.f?=?None

????def?tearDown(self):
????????if?self.f?and?not?self.f.closed:
????????????self.f.close()
????????unlink(TESTFN)

????def?test_fcntl_fileno(self):
????????#?the?example?from?the?library?docs
????????self.f?=?open(TESTFN?‘wb‘)
????????rv?=?fcntl.fcntl(self.f.fileno()?fcntl.F_SETFL?os.O_NONBLOCK)
????????if?verbose:
????????????print(‘Status?from?fcntl?with?O_NONBLOCK:?‘?rv)
????????rv?=?fcntl.fcntl(self.f.fileno()?fcntl.F_SETLKW?lockdata)
????????if?verbose:
????????????print(‘String?from?fcntl?with?F_SETLKW:?‘?repr(rv))
????????self.f.close()

????def?test_fcntl_file_descriptor(self):
????????#?again?but?pass?the?file?rather?than?numeric?descriptor
????????self.f?=?open(TESTFN?‘wb‘)
????????rv?=?fcntl.fcntl(self.f?fcntl.F_SETFL?os.O_NONBLOCK)
????????if?verbose:
????????????print(‘Status?from?fcntl?with?O_NONBLOCK:?‘?rv)
????????rv?=?fcntl.fcntl(self.f?fcntl.F_SETLKW?lockdata)
????????if?verbose:
????????????print(‘String?from?fcntl?with?F_SETLKW:?‘?repr(rv))
????????self.f.close()

????def?test_fcntl_bad_file(self):
??

評論

共有 條評論

相關(guān)資源