Skip to content

Commit d02204a

Browse files
Merge pull request #1 from scottwilliambeasley/scottwilliambeasley-patch-1
fix bug with regex matching when using Python 3+
2 parents 1e08f70 + b15a50a commit d02204a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

apache_log_parser/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import re
22
from datetime import datetime, tzinfo, timedelta
3+
import sys
34

45
import user_agents
56

@@ -220,6 +221,8 @@ def __init__(self, format_string):
220221
self.names = tuple(self.names)
221222

222223
def parse(self, log_line):
224+
if (sys.version_info.major > 2):
225+
log_line = log_line.decode('utf-8')
223226
match = self.log_line_regex.match(log_line)
224227
if match is None:
225228
raise LineDoesntMatchException(log_line=log_line, regex=self.log_line_regex.pattern)

0 commit comments

Comments
 (0)