From 376ad06df03e59ebf0796b2f475417150e82252d Mon Sep 17 00:00:00 2001 Message-Id: <376ad06df03e59ebf0796b2f475417150e82252d.1713572315.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 4 Oct 2009 13:34:01 +0100 Subject: [PATCH 1/1] *.pyx: Replace __new__ with __cinit__ like the program says. Organization: Straylight/Edgeware From: Mark Wooding Apparently __new__ is going to get new semantics some day. The old version always was rather mad. --- assoc.pyx | 2 +- atom.pyx | 2 +- bres.pyx | 4 ++-- codec.pyx.in | 4 ++-- conn.pyx | 2 +- crc32.pyx | 2 +- fwatch.pyx | 2 +- ident.pyx | 2 +- lbuf.pyx | 2 +- mapping.pyx | 4 ++-- pkbuf.pyx | 2 +- sel-file.pyx | 2 +- sel-timer.pyx | 2 +- selbuf.pyx | 2 +- selpk.pyx | 2 +- sig.pyx | 2 +- sym.pyx | 2 +- unihash.pyx | 4 ++-- url.pyx | 4 ++-- 19 files changed, 24 insertions(+), 24 deletions(-) diff --git a/assoc.pyx b/assoc.pyx index 535fa03..e2ba4ee 100644 --- a/assoc.pyx +++ b/assoc.pyx @@ -75,7 +75,7 @@ cdef class AssocTable (Mapping): cdef class _AssocIter (_MapIterator): cdef AssocTable t cdef assoc_iter i - def __new__(me, AssocTable t): + def __cinit__(me, AssocTable t): me.t = t assoc_mkiter(&me.i, &me.t._t) cdef void *_next(me): diff --git a/atom.pyx b/atom.pyx index 5c0cde6..9892ba5 100644 --- a/atom.pyx +++ b/atom.pyx @@ -27,7 +27,7 @@ cdef class AtomIter: cdef atom_iter _i - def __new__(me): + def __cinit__(me): atom_mkiter(&me._i, ATOM_GLOBAL) def __next__(me): cdef atom *a diff --git a/bres.pyx b/bres.pyx index 0ddfb11..8c32fd5 100644 --- a/bres.pyx +++ b/bres.pyx @@ -70,7 +70,7 @@ cdef class SelResolve: return _maybecall(me._failed, ()) cdef class SelResolveByName (SelResolve): - def __new__(me, char *name, resolvedproc = None, failedproc = None, + def __cinit__(me, char *name, resolvedproc = None, failedproc = None, *hunoz, **hukairz): me._resolved = _checkcallable(resolvedproc, 'resolved proc') me._failed = _checkcallable(failedproc, 'failed proc') @@ -80,7 +80,7 @@ cdef class SelResolveByName (SelResolve): pass cdef class SelResolveByAddr (SelResolve): - def __new__(me, char *addr, resolvedproc = None, failedproc = None, + def __cinit__(me, char *addr, resolvedproc = None, failedproc = None, *hunoz, **hukairz): cdef in_addr ia if not inet_aton(addr, &ia): diff --git a/codec.pyx.in b/codec.pyx.in index e683233..971c899 100644 --- a/codec.pyx.in +++ b/codec.pyx.in @@ -39,7 +39,7 @@ cdef extern from 'mLib/%PREFIX%.h': cdef class %CLASS%Encode: cdef %PREFIX%_ctx ctx - def __new__(me, *hunoz, **hukairz): + def __cinit__(me, *hunoz, **hukairz): _%PREFIX%_init(&me.ctx) me.ctx.indent = NULL def __init__(me, indent = '\n', maxline = 72): @@ -90,7 +90,7 @@ def %PREFIX%_encode(text, *arg, **kw): cdef class %CLASS%Decode: cdef %PREFIX%_ctx ctx - def __new__(me, *hunoz, **hukairz): + def __cinit__(me, *hunoz, **hukairz): _%PREFIX%_init(&me.ctx) me.ctx.indent = NULL def decode(me, text): diff --git a/conn.pyx b/conn.pyx index 04b9ffa..7313303 100644 --- a/conn.pyx +++ b/conn.pyx @@ -31,7 +31,7 @@ cdef class SelConnect: cdef readonly object socket cdef _connected cdef _error - def __new__(me, sk, connectedproc = None, errorproc = None, + def __cinit__(me, sk, connectedproc = None, errorproc = None, *hunoz, **hukairz): conn_fd(&me.c, &_sel, sk.fileno(), _connfunc, me) me._activep = 1 diff --git a/crc32.pyx b/crc32.pyx index f76ef5e..b5d8374 100644 --- a/crc32.pyx +++ b/crc32.pyx @@ -27,7 +27,7 @@ cdef class CRC32: cdef uint32 _a - def __new__(me, *hunoz, **hukairz): + def __cinit__(me, *hunoz, **hukairz): me._a = 0 def __init__(me): pass diff --git a/fwatch.pyx b/fwatch.pyx index ab0ae25..d058976 100644 --- a/fwatch.pyx +++ b/fwatch.pyx @@ -28,7 +28,7 @@ cdef class FWatch: cdef fwatch fw cdef public file - def __new__(me, file): + def __cinit__(me, file): me._init(file) def __init__(me, file): me._init(file) diff --git a/ident.pyx b/ident.pyx index 8f143ec..47de397 100644 --- a/ident.pyx +++ b/ident.pyx @@ -52,7 +52,7 @@ cdef class SelIdentify: cdef _error cdef _failed cdef _bogus - def __new__(me, sk, + def __cinit__(me, sk, userproc = None, bogusproc = None, badproc = None, errorproc = None, failedproc = None, *hunoz, **hukairz): diff --git a/lbuf.pyx b/lbuf.pyx index fe9f00e..a66e3a3 100644 --- a/lbuf.pyx +++ b/lbuf.pyx @@ -32,7 +32,7 @@ cdef class LineBuffer: cdef lbuf b cdef _line cdef _eof - def __new__(me, lineproc = None, eofproc = None, *hunoz, **hukairz): + def __cinit__(me, lineproc = None, eofproc = None, *hunoz, **hukairz): lbuf_init(&me.b, _lbfunc, me) me._line = _checkcallable(lineproc, 'line proc') me._eof = _checkcallable(eofproc, 'eof proc') diff --git a/mapping.pyx b/mapping.pyx index 551261e..a7c1e26 100644 --- a/mapping.pyx +++ b/mapping.pyx @@ -50,7 +50,7 @@ cdef class Mapping: raise SystemError, 'unimplemented _iter' ## Initialization - def __new__(me, *hunoz, **hukairz): + def __cinit__(me, *hunoz, **hukairz): me._init() def __init__(me, stuff = None, **kw): me.update(stuff, kw) @@ -169,7 +169,7 @@ cdef class MapIterBase: cdef _MapIterator i cdef int _init(me) except -1: raise TypeError, 'abstract class' - def __new__(me): + def __cinit__(me): me.i = m._iter() me._init() def __iter__(me): diff --git a/pkbuf.pyx b/pkbuf.pyx index 9bad268..591bc41 100644 --- a/pkbuf.pyx +++ b/pkbuf.pyx @@ -29,7 +29,7 @@ cdef class PacketBuffer: cdef pkbuf pk cdef _packet cdef _eof - def __new__(me, packetproc = None, eofproc = None, *hunoz, **hukairz): + def __cinit__(me, packetproc = None, eofproc = None, *hunoz, **hukairz): pkbuf_init(&me.pk, _pkfunc, me) me._packet = _checkcallable(packetproc, 'packet proc') me._eof = _checkcallable(eofproc, 'eof proc') diff --git a/sel-file.pyx b/sel-file.pyx index 53af55e..df04938 100644 --- a/sel-file.pyx +++ b/sel-file.pyx @@ -34,7 +34,7 @@ cdef class SelFile: cdef int _activep cdef readonly unsigned mode cdef _readyfunc - def __new__(me, fd, int mode = SEL_READ, readyproc = None, + def __cinit__(me, fd, int mode = SEL_READ, readyproc = None, *hunoz, **hukairz): if (mode != _SEL_READ and mode != _SEL_WRITE and diff --git a/sel-timer.pyx b/sel-timer.pyx index 6bc4e28..24d3d24 100644 --- a/sel-timer.pyx +++ b/sel-timer.pyx @@ -38,7 +38,7 @@ cdef class SelTimer: cdef int _activep cdef readonly double time cdef _timer - def __new__(me, double when, timerproc = None, *hunoz, **hukairz): + def __cinit__(me, double when, timerproc = None, *hunoz, **hukairz): cdef timeval tv _floattotv(&tv, when) sel_addtimer(&_sel, &me.t, &tv, _timerfunc, me) diff --git a/selbuf.pyx b/selbuf.pyx index e0586fc..8f6901c 100644 --- a/selbuf.pyx +++ b/selbuf.pyx @@ -29,7 +29,7 @@ cdef class SelLineBuffer: cdef selbuf b cdef _line cdef _eof - def __new__(me, fd, lineproc = None, eofproc = None, *hunoz, **hukairz): + def __cinit__(me, fd, lineproc = None, eofproc = None, *hunoz, **hukairz): selbuf_init(&me.b, &_sel, _getfd(fd), _selbfunc, me) selbuf_disable(&me.b) me._line = _checkcallable(lineproc, 'line proc') diff --git a/selpk.pyx b/selpk.pyx index 59d500f..275fcfc 100644 --- a/selpk.pyx +++ b/selpk.pyx @@ -29,7 +29,7 @@ cdef class SelPacketBuffer: cdef selpk p cdef _packet cdef _eof - def __new__(me, fd, packetproc = None, eofproc = None, *hunoz, **hukairz): + def __cinit__(me, fd, packetproc = None, eofproc = None, *hunoz, **hukairz): selpk_init(&me.p, &_sel, _getfd(fd), _selpkfunc, me) selpk_disable(&me.p) me._packet = _checkcallable(packetproc, 'packet proc') diff --git a/sig.pyx b/sig.pyx index e10913c..f71ea48 100644 --- a/sig.pyx +++ b/sig.pyx @@ -32,7 +32,7 @@ cdef class SelSignal: cdef int _activep cdef readonly int signal cdef _signalled - def __new__(me, int sig, signalledproc = None, *hunoz, **hukairz): + def __cinit__(me, int sig, signalledproc = None, *hunoz, **hukairz): if sig < 0 or sig >= signal.NSIG: raise ValueError, 'signal number out of range' me.signal = sig diff --git a/sym.pyx b/sym.pyx index 8de6938..946162b 100644 --- a/sym.pyx +++ b/sym.pyx @@ -73,7 +73,7 @@ cdef class SymTable (Mapping): cdef class _SymIter (_MapIterator): cdef SymTable t cdef sym_iter i - def __new__(me, SymTable t): + def __cinit__(me, SymTable t): me.t = t sym_mkiter(&me.i, &me.t._t) cdef void *_next(me): diff --git a/unihash.pyx b/unihash.pyx index 565959f..5326ad2 100644 --- a/unihash.pyx +++ b/unihash.pyx @@ -31,7 +31,7 @@ def setglobalkey(uint32 k): cdef class Key: cdef unihash_info _i cdef uint32 _k - def __new__(me, uint32 k): + def __cinit__(me, uint32 k): unihash_setkey(&me._i, k) me._k = k property k: @@ -42,7 +42,7 @@ cdef class Unihash: cdef uint32 _a cdef readonly Key key cdef unihash_info *_i - def __new__(me, key = None): + def __cinit__(me, key = None): cdef Key k me.key = key if key is None: diff --git a/url.pyx b/url.pyx index d4ed121..613630d 100644 --- a/url.pyx +++ b/url.pyx @@ -29,7 +29,7 @@ cdef class URLEncode: cdef url_ectx ctx cdef dstr d - def __new__(me, *hunoz, **hukairz): + def __cinit__(me, *hunoz, **hukairz): url_initenc(&me.ctx) DCREATE(&me.d) def __init__(me, strictp = False, laxp = False, semip = False): @@ -79,7 +79,7 @@ cdef class URLDecode: cdef url_dctx ctx cdef char *p - def __new__(me, *hunoz, **hukairz): + def __cinit__(me, *hunoz, **hukairz): me.p = xstrdup('') url_initdec(&me.ctx, me.p) def __init__(me, char *string, semip = False): -- [mdw]