1. Michał Górny
  2. gentoopm


Michał Górny  committed f19e496

StringCompat: raise AttributeError when accessing invalid str attrs.

StringCompat's __getattr__() may be called because of a random
AttributeError. Thus, we should raise AttributeError when user tries to
access an invalid attr. Otherwise, we may end up with an infinite
stringification loop.

  • Participants
  • Parent commits c891e72
  • Branches master

Comments (0)

Files changed (1)

File gentoopm/util.py

View file
 		return hasattr(str, k)
 	def __getattr__(self, k):
+		if not self.__hasattr__(k):
+			raise AttributeError(k)
 		return getattr(str(self), k)
 	# other useful special methods