summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/fixes/fix_xreadlines.py
blob: 8857759afea4829a5ffd23434ddba4a37e45c526 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Fix "for x in f.xreadlines()" -> "for x in f".

This fixer will also convert g(f.xreadlines) into g(f.__iter__)."""
# Author: Collin Winter

# Local imports
from .import basefix
from .util import Name


class FixXreadlines(basefix.BaseFix):
    PATTERN = """
    power< call=any+ trailer< '.' 'xreadlines' > trailer< '(' ')' > >
    |
    power< any+ trailer< '.' no_call='xreadlines' > >
    """

    def transform(self, node, results):
        no_call = results.get("no_call")

        if no_call:
            no_call.replace(Name("__iter__", prefix=no_call.get_prefix()))
        else:
            node.replace([x.clone() for x in results["call"]])
span class='decoration'>Victor Stinner2010-04-201-0/+2 * Fix Issue #4841: timeout is now applied for connections resulting from PORT/E...Giampaolo Rodolà2010-04-191-0/+3 * Fixed #8463: added missing reference to bztar in shutil's documentation.Tarek Ziadé2010-04-191-0/+2 * Issue #8438: Remove reference to the missing "surrogateescape" encodingAntoine Pitrou2010-04-191-0/+3 * Fix for issue #7072Ronald Oussoren2010-04-181-0/+2 * Fix Issue #3817: 225 is now considered a valid response code for ABORGiampaolo Rodolà2010-04-181-0/+3 * Issue #8279: Fix test_gdb failures.Martin v. Löwis2010-04-171-0/+2 * Add Giampaolo.Martin v. Löwis2010-04-171-0/+3 * Issue #8322: Add a *ciphers* argument to SSL sockets, so as to change theAntoine Pitrou2010-04-171-0/+3 * Issue #3864: Skip three test_signal tests on freebsd6 due to platform bug.R. David Murray2010-04-171-0/+3 * have a clear error when passing something > sys.maxsize to bytearrayBenjamin Peterson2010-04-161-0/+3 * Fix issue2987: RFC2732 support for urlparse (IPv6 addresses)Senthil Kumaran2010-04-161-0/+3 * #5341: typo.Georg Brandl2010-04-141-1/+1 * Issue #5277: Fix quote counting when parsing RFC 2231 encoded parameters.R. David Murray2010-04-132-0/+4 * Issue #7585: use tab between components in unified and context diff headers.R. David Murray2010-04-122-0/+5 * Issue #7472: ISO-2022 charsets now consistently use 7bit CTE.R. David Murray2010-04-121-0/+4 * Issue #8330: Fix expected output in test_gdb.Martin v. Löwis2010-04-121-0/+2 * Fix misplaced items and incorrect title.Antoine Pitrou2010-04-111-11/+11 * Issue #8374: Update the internal alias table in the :mod:`locale` moduleAntoine Pitrou2010-04-11