Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix lack for operator.methodcaller in Python <2.6

  • Loading branch information...
commit 12e04521b5615cb22e9fe5966b2e243c62e319eb 1 parent c192fcb
@SimonSapin authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 cssselect/parser.py
View
7 cssselect/parser.py
@@ -584,7 +584,12 @@ def _compile(pattern):
_sub_newline_escape =re.compile(r'\\(?:\n|\r\n|\r|\f)').sub
# Same as r'\1', but faster on CPython
-_replace_simple = operator.methodcaller('group', 1)
+if hasattr(operator, 'methodcaller'):
+ # Python 2.6+
+ _replace_simple = operator.methodcaller('group', 1)
+else:
+ def _replace_simple(match):
+ return match.group(1)
def _replace_unicode(match):
codepoint = int(match.group(1), 16)
Please sign in to comment.
Something went wrong with that request. Please try again.