_walkdirs_win32.pyx cannot be compiled with Python 2.4

Bug #277475 reported by Alexander Belchenko
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Unassigned

Bug Description

bzr.dev revno.3763 , Pyrex 0.9.6.4, Python 2.4.4:

pyrexc bzrlib/_walkdirs_win32.pyx --> bzrlib/_walkdirs_win32.c
building 'bzrlib._walkdirs_win32' extension
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWIN32 -IC:\Python\2.4.4\include -IC:\Python\2.4.4\PC /Tcbzrlib/_walkdirs_win32.c /Fobuild\temp.win32-2.4\Release\bzrlib/_walkdirs_win32.obj
_walkdirs_win32.c
bzrlib\_walkdirs_win32.c(825) : error C2065: 'T_LONGLONG' : undeclared identifier
bzrlib\_walkdirs_win32.c(825) : error C2099: initializer is not a constant
Building of "bzrlib._walkdirs_win32" extension failed, will use the Python version instead

This extension cannot be compiled because T_LONGLONG absent in Python 2.4.

Code in question:

cdef class _Win32Stat:
    """Represent a 'stat' result generated from WIN32_FIND_DATA"""

    cdef readonly int st_mode
    cdef readonly double st_ctime
    cdef readonly double st_mtime
    cdef readonly double st_atime
    cdef readonly __int64 st_size

    # os.stat always returns 0, so we hard code it here
    cdef readonly int st_dev
    cdef readonly int st_ino

Interesting part is cdef readonly __int64 st_size. Pyrex generate following C-code:

static struct PyMemberDef __pyx_members_15_walkdirs_win32__Win32Stat[] = {
  {"st_mode", T_INT, offsetof(struct __pyx_obj_15_walkdirs_win32__Win32Stat, st_mode), READONLY, 0},
  {"st_ctime", T_DOUBLE, offsetof(struct __pyx_obj_15_walkdirs_win32__Win32Stat, st_ctime), READONLY, 0},
  {"st_mtime", T_DOUBLE, offsetof(struct __pyx_obj_15_walkdirs_win32__Win32Stat, st_mtime), READONLY, 0},
  {"st_atime", T_DOUBLE, offsetof(struct __pyx_obj_15_walkdirs_win32__Win32Stat, st_atime), READONLY, 0},
  {"st_size", T_LONGLONG, offsetof(struct __pyx_obj_15_walkdirs_win32__Win32Stat, st_size), READONLY, 0},
  {"st_dev", T_INT, offsetof(struct __pyx_obj_15_walkdirs_win32__Win32Stat, st_dev), READONLY, 0},
  {"st_ino", T_INT, offsetof(struct __pyx_obj_15_walkdirs_win32__Win32Stat, st_ino), READONLY, 0},
  {0, 0, 0, 0, 0}
};

When MSVC trying to compile this it break with error:

bzrlib\_walkdirs_win32.c(1100) : error C2065: 'T_LONGLONG' : undeclared identifier
bzrlib\_walkdirs_win32.c(1100) : error C2099: initializer is not a constant

I'm grepping 2.4 and 2.5 sources and found that in 2.5 this symbol defined in include/structmember.h
as following:

#ifdef HAVE_LONG_LONG
#define T_LONGLONG 17
#define T_ULONGLONG 18
#endif /* HAVE_LONG_LONG */

But this definition is not there in Python 2.4.

I'm not sure that adding this definition manually will helps: if Python 2.4 has no support for this type it will likely to segfault in runtime.

John A Meinel (jameinel)
Changed in bzr:
importance: Undecided → High
milestone: none → 1.9rc1
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.