~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_rio_py.py

  • Committer: Jelmer Vernooij
  • Date: 2009-05-14 21:29:57 UTC
  • mto: (4290.1.9 rio-serializer2)
  • mto: This revision was merged to the branch mainline in revision 4368.
  • Revision ID: jelmer@samba.org-20090514212957-fdg0uxi17n5j93ui
Extend valid_tags tests a bit, test that stanza pairs contain the right types.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
_tag_re = re.compile(r'^[-a-zA-Z0-9_]+$')
26
26
def _valid_tag(tag):
 
27
    if type(tag) != str:
 
28
        raise TypeError(tag)
27
29
    return bool(_tag_re.match(tag))
28
30
 
29
31
 
30
32
def _read_stanza_utf8(line_iter):
31
 
    unicode_iter = (line.decode('utf-8') for line in line_iter)
32
 
    return _read_stanza_unicode(unicode_iter)
 
33
    def iter_unicode_lines():
 
34
        for line in line_iter:
 
35
            if type(line) != str:
 
36
                raise TypeError(line)
 
37
            yield line.decode('utf-8')
 
38
    return _read_stanza_unicode(iter_unicode_lines())
33
39
 
34
40
 
35
41
def _read_stanza_unicode(unicode_iter):