Skip to content

fix bug with regex matching when using Python 3+#1

Merged
scottwilliambeasley merged 1 commit intomasterfrom
scottwilliambeasley-patch-1
Apr 8, 2018
Merged

fix bug with regex matching when using Python 3+#1
scottwilliambeasley merged 1 commit intomasterfrom
scottwilliambeasley-patch-1

Conversation

@scottwilliambeasley
Copy link
Copy Markdown
Owner

@scottwilliambeasley scottwilliambeasley commented Apr 8, 2018

When using Python 3+, the ff error is generated:

File "/home/$USER/.local/lib/python3.6/site-packages/apache_log_parser/__init__.py", line 246, in parse
match = self.log_line_regex.match(log_line)
TypeError: cannot use a string pattern on a bytes-like object 

Python 3+ will return the log_line as a bytes-like object , which will not a compatible with the method signature.

My proposed fix detects if the version of Python is 3+ and then decodes it into utf-8 as necessary.
Makes the code work as expected on Python 3+.

@scottwilliambeasley scottwilliambeasley merged commit d02204a into master Apr 8, 2018
@scottwilliambeasley scottwilliambeasley deleted the scottwilliambeasley-patch-1 branch April 8, 2018 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant