1
"""Fixer that turns 1L into 1, 0755 into 0o755.
3
# Copyright 2007 Georg Brandl.
4
# Licensed to PSF under a Contributor Agreement.
7
from ..pgen2 import token
8
from .. import fixer_base
9
from ..fixer_util import Number
12
class FixNumliterals(fixer_base.BaseFix):
13
# This is so simple that we don't need the pattern compiler.
15
def match(self, node):
17
return (node.type == token.NUMBER and
18
(node.value.startswith("0") or node.value[-1] in "Ll"))
20
def transform(self, node, results):
24
elif val.startswith('0') and val.isdigit() and len(set(val)) > 1:
27
return Number(val, prefix=node.get_prefix())