~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_btree_serializer_pyx.pyx

  • Committer: Patch Queue Manager
  • Date: 2016-04-21 04:10:52 UTC
  • mfrom: (6616.1.1 fix-en-user-guide)
  • Revision ID: pqm@pqm.ubuntu.com-20160421041052-clcye7ns1qcl2n7w
(richard-wilbur) Ensure build of English use guide always uses English text
 even when user's locale specifies a different language. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
496
496
    return val
497
497
 
498
498
 
499
 
cdef _format_record_py24(gc_chk_sha1_record *record):
500
 
    """Python2.4 PyString_FromFormat doesn't have %u.
501
 
 
502
 
    It only has %d and %ld. We would really like to even have %llu, which
503
 
    is only in python2.7. So we go back into casting to regular objects.
504
 
    """
505
 
    return "%s %s %s %s" % (record.block_offset, record.block_length,
506
 
                            record.record_start, record.record_end)
507
 
 
508
 
 
509
499
cdef _format_record(gc_chk_sha1_record *record):
510
500
    # This is inefficient to go from a logical state back to a
511
501
    # string, but it makes things work a bit better internally for now.
513
503
        # %llu is what we really want, but unfortunately it was only added
514
504
        # in python 2.7... :(
515
505
        block_offset_str = str(record.block_offset)
516
 
        value = PyString_FromFormat('%s %lu %lu %lu',
 
506
        value = PyString_FromFormat('%s %u %u %u',
517
507
                                PyString_AS_STRING(block_offset_str),
518
508
                                record.block_length,
519
509
                                record.record_start, record.record_end)
520
510
    else:
521
 
        value = PyString_FromFormat('%lu %lu %lu %lu',
 
511
        value = PyString_FromFormat('%lu %u %u %u',
522
512
                                    <unsigned long>record.block_offset,
523
513
                                    record.block_length,
524
514
                                    record.record_start, record.record_end)
525
515
    return value
526
516
 
527
 
ctypedef object (*formatproc)(gc_chk_sha1_record *)
528
 
cdef formatproc _record_formatter
529
 
_record_formatter = _format_record
530
 
if sys.version_info[:2] == (2, 4):
531
 
    _record_formatter = _format_record_py24
532
 
 
533
517
 
534
518
cdef class GCCHKSHA1LeafNode:
535
519
    """Track all the entries for a given leaf node."""
593
577
        cdef StaticTuple value_and_refs
594
578
        cdef StaticTuple empty
595
579
        value_and_refs = StaticTuple_New(2)
596
 
        value = _record_formatter(record)
 
580
        value = _format_record(record)
597
581
        Py_INCREF(value)
598
582
        StaticTuple_SET_ITEM(value_and_refs, 0, value)
599
583
        # Always empty refs