New issue 3125: Logical error in detecting dirent.d_type https://bitbucket.org/pypy/pypy/issues/3125/logical-error-in-detecting-direntd_type
Игорь Пашев: Hi guys! I am porting Debian’s package pypy to Dyson which is Debian on illumos kernel and, so far, libc. Its dirent structure does not have `d_type` field, but for sure has `d_name`. And when I am building pypy I am getting this error: ``` [translation:ERROR] AttributeError: <Struct dirent { c__pad0, c__pad1, c__pad2, c__pad3, c__pad4, c__pad5, c__pad6, c__pad7, c__pad8, c__pad9, c__pad10, c__pad11, c__pad12, c__pad13, c__pad14, c__pad15, c__pad16, c__pad17, c_ _pad18, c__pad19, c__pad20, c__pad21, c__pad22, c__pad23 }> instance has no field 'c_d_name' Processing block: block@61[rewind_0...] is a <class 'rpython.flowspace.flowcontext.SpamBlock'> in (rpython.rlib.rposix:833)_listdir containing the following operations: v831 = getattr(direntp_0, ('c_d_name')) namep_0 = simple_call((function force_cast), (Ptr arrayPtr), v831) name_5 = simple_call((function charp2str), namep_0) v832 = ne(name_5, ('.')) v833 = bool(v832) --end-- ``` Looking at this code in rpython/rlib/rposix.py… well after hard time debugging :\)… I have found a logical error: ```python if not _WIN32: class CConfig: _compilation_info_ = eci DIRENT = rffi_platform.Struct('struct dirent', [('d_name', lltype.FixedSizeArray(rffi.CHAR, 1)), ('d_ino', lltype.Signed)] + [('d_type', rffi.INT)] if HAVE_D_TYPE else []) if HAVE_D_TYPE: DT_UNKNOWN = rffi_platform.ConstantInteger('DT_UNKNOWN') DT_REG = rffi_platform.ConstantInteger('DT_REG') DT_DIR = rffi_platform.ConstantInteger('DT_DIR') DT_LNK = rffi_platform.ConstantInteger('DT_LNK') DIRP = rffi.COpaquePtr('DIR') dirent_config = rffi_platform.configure(CConfig) ``` Guess what! :\) Yes, if `HAVE_D_TYPE` is `False`, we get empty list, without `d_name`, `d_ino`. _______________________________________________ pypy-issue mailing list pypy-issue@python.org https://mail.python.org/mailman/listinfo/pypy-issue