Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/memoized.py

Issue 2580293002: Style change: Rename error variables "e" -> "error" (Closed)
Patch Set: Rebase and fix formatter unittest. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/memoized_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 Google Inc. All rights reserved. 1 # Copyright (c) 2010 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 27 matching lines...) Expand all
38 self._function = function 38 self._function = function
39 self._results_cache = {} 39 self._results_cache = {}
40 40
41 def __call__(self, *args): 41 def __call__(self, *args):
42 try: 42 try:
43 return self._results_cache[args] 43 return self._results_cache[args]
44 except KeyError: 44 except KeyError:
45 result = self._function(*args) 45 result = self._function(*args)
46 self._results_cache[args] = result 46 self._results_cache[args] = result
47 return result 47 return result
48 except TypeError as e: 48 except TypeError as error:
49 raise TypeError( 49 raise TypeError(
50 'Cannot call memoized function %s with unhashable ' 50 'Cannot call memoized function %s with unhashable '
51 'arguments: %s' % (self._function.__name__, e.message)) 51 'arguments: %s' % (self._function.__name__, error.message))
52 52
53 # Use python "descriptor" protocol __get__ to appear 53 # Use python "descriptor" protocol __get__ to appear
54 # invisible during property access. 54 # invisible during property access.
55 def __get__(self, instance, owner): 55 def __get__(self, instance, owner):
56 # Return a function partial with object already bound as self. 56 # Return a function partial with object already bound as self.
57 return functools.partial(self.__call__, instance) 57 return functools.partial(self.__call__, instance)
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/memoized_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698