Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/email/_parseaddr.py

    r2 r391  
    1414    ]
    1515
    16 import time
     16import time, calendar
    1717
    1818SPACE = ' '
     
    108108    except ValueError:
    109109        return None
     110    # Check for a yy specified in two-digit format, then convert it to the
     111    # appropriate four-digit format, according to the POSIX standard. RFC 822
     112    # calls for a two-digit yy, but RFC 2822 (which obsoletes RFC 822)
     113    # mandates a 4-digit yy. For more information, see the documentation for
     114    # the time module.
     115    if yy < 100:
     116        # The year is between 1969 and 1999 (inclusive).
     117        if yy > 68:
     118            yy += 1900
     119        # The year is between 2000 and 2068 (inclusive).
     120        else:
     121            yy += 2000
    110122    tzoffset = None
    111123    tz = tz.upper()
     
    139151
    140152def mktime_tz(data):
    141     """Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp."""
     153    """Turn a 10-tuple as returned by parsedate_tz() into a POSIX timestamp."""
    142154    if data[9] is None:
    143155        # No zone info, so localtime is better assumption than GMT
    144156        return time.mktime(data[:8] + (-1,))
    145157    else:
    146         t = time.mktime(data[:8] + (0,))
    147         return t - data[9] - time.timezone
     158        t = calendar.timegm(data)
     159        return t - data[9]
    148160
    149161
    150162def quote(str):
    151     """Add quotes around a string."""
     163    """Prepare string to be used in a quoted string.
     164
     165    Turns backslash and double quote characters into quoted pairs.  These
     166    are the only characters that need to be quoted inside a quoted string.
     167    Does not add the surrounding double quotes.
     168    """
    152169    return str.replace('\\', '\\\\').replace('"', '\\"')
    153170
     
    307324                self.pos += 1
    308325            elif self.field[self.pos] == '"':
    309                 aslist.append('"%s"' % self.getquote())
     326                aslist.append('"%s"' % quote(self.getquote()))
    310327            elif self.field[self.pos] in self.atomends:
    311328                break
Note: See TracChangeset for help on using the changeset viewer.