~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Lib/lib2to3/fixes/fix_numliterals.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
class FixNumliterals(fixer_base.BaseFix):
13
13
    # This is so simple that we don't need the pattern compiler.
14
14
 
 
15
    _accept_type = token.NUMBER
 
16
 
15
17
    def match(self, node):
16
18
        # Override
17
 
        return (node.type == token.NUMBER and
18
 
                (node.value.startswith("0") or node.value[-1] in "Ll"))
 
19
        return (node.value.startswith(u"0") or node.value[-1] in u"Ll")
19
20
 
20
21
    def transform(self, node, results):
21
22
        val = node.value
22
 
        if val[-1] in 'Ll':
 
23
        if val[-1] in u'Ll':
23
24
            val = val[:-1]
24
 
        elif val.startswith('0') and val.isdigit() and len(set(val)) > 1:
25
 
            val = "0o" + val[1:]
 
25
        elif val.startswith(u'0') and val.isdigit() and len(set(val)) > 1:
 
26
            val = u"0o" + val[1:]
26
27
 
27
 
        return Number(val, prefix=node.get_prefix())
 
28
        return Number(val, prefix=node.prefix)