Revision 15688021 pithos/lib/hashfiler/noder.py

b/pithos/lib/hashfiler/noder.py
19 19
        ## all strings start with the null string,
20 20
        ## therefore we have to approximate strnextling('')
21 21
        ## with the last unicode character supported by python
22
        return unichr(0x10ffff)
22
        ## 0x10ffff for wide (32-bit unicode) python builds
23
        ## 0x00ffff for narrow (16-bit unicode) python builds
24
        ## We will not autodetect. 0xffff is safe enough.
25
        return unichr(0xffff)
23 26
    s = prefix[:-1]
24 27
    c = ord(prefix[-1])
25
    if c >= 0x10ffff:
28
    if c >= 0xffff:
26 29
        raise RuntimeError
27 30
    s += unichr(c+1)
28 31
    return s
......
30 33
def strprevling(prefix):
31 34
    """return an approximation of the last unicode string
32 35
       less than but not starting with given prefix.
33
       strprevling('hello') -> 'helln\\x10ffff'
36
       strprevling(u'hello') -> u'helln\\xffff'
34 37
    """
35 38
    if not prefix:
36 39
        ## There is no prevling for the null string
......
38 41
    s = prefix[:-1]
39 42
    c = ord(prefix[-1])
40 43
    if c > 0:
41
        s += unichr(c-1) + unichr(0x10ffff)
44
        s += unichr(c-1) + unichr(0xffff)
42 45
    return s
43 46

  
44 47
import re

Also available in: Unified diff