[Python-bugs-list] [ python-Bugs-530285 ] redefining SRE_CODE in Modules/sre.h

noreply@sourceforge.net noreply@sourceforge.net
Fri, 15 Mar 2002 10:05:56 -0800


Bugs item #530285, was opened at 2002-03-15 07:44
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=530285&group_id=5470

Category: Regular Expressions
Group: Python 2.2.1 candidate
Status: Open
Resolution: None
Priority: 5
Submitted By: Neal Norwitz (nnorwitz)
Assigned to: Fredrik Lundh (effbot)
Summary: redefining SRE_CODE in Modules/sre.h

Initial Comment:
Taken from Modules/sre.h:

/* size of a code word (must be unsigned short or
   larger, and
   large enough to hold a Py_UNICODE character) */
#ifdef Py_UNICODE_WIDE
#define SRE_CODE unsigned long
#else
#define SRE_CODE unsigned short
#endif

#define SRE_CODE unsigned short

------------------

SRE_CODE is always an unsigned short.

----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2002-03-15 13:05

Message:
Logged In: YES 
user_id=33168

Regardless of the value of Py_UNICODE_WIDE, SRE_CODE will be
defined to unsigned short after the #ifdef because of the
#define after the #ifdef.

There is actually a warning produced that SRE_CODE is
redefined if Py_UNICODE_WIDE is set.

If SRE_CODE needs to be differerent, the 3rd #define of
SRE_CODE should be removed.  I tried this a while ago and
purify reported more errors.  (purify is still broken, so I
can't give any current info.)

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-03-15 12:50

Message:
Logged In: YES 
user_id=21627

What do you mean with "SRE_CODE is always an unsigned
short"; if sre.h defines it as something different, it is
different.

It also needs to be different for Py_UNICODE_WIDE: For
SRE_OP_LITERAL, a Py_UNICODE is the argument. If Py_UNICODE
is 4 bytes, SRE_CODE must be also four bytes.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=530285&group_id=5470