~pythonregexp2.7/python/issue2636-22

« back to all changes in this revision

Viewing changes to Lib/collections.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-06-09 14:36:32 UTC
  • mfrom: (39021.1.402 Regexp-2.6)
  • Revision ID: darklord@timehorse.com-20080609143632-wwwkx92u1t5l7yd3
Merged in changes from the latest python source snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
            result = self._make(map(kwds.pop, %(field_names)r, self))
83
83
            if kwds:
84
84
                raise ValueError('Got unexpected field names: %%r' %% kwds.keys())
85
 
            return result \n\n''' % locals()
 
85
            return result \n
 
86
        def __getnewargs__(self):
 
87
            return tuple(self) \n\n''' % locals()
86
88
    for i, name in enumerate(field_names):
87
89
        template += '        %s = property(itemgetter(%d))\n' % (name, i)
88
90
    if verbose:
89
91
        print template
90
92
 
91
 
    # Execute the template string in a temporary namespace
92
 
    namespace = dict(itemgetter=_itemgetter)
 
93
    # Execute the template string in a temporary namespace and
 
94
    # support tracing utilities by setting a value for frame.f_globals['__name__']
 
95
    namespace = dict(itemgetter=_itemgetter, __name__='namedtuple_%s' % typename)
93
96
    try:
94
97
        exec template in namespace
95
98
    except SyntaxError, e: