Skip to content

Fixed encoding error when using --debug in python 3 #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ def setdebug():
logformat = "%(levelname)8s %(message)s"
logger.setLevel(loglevel)

if streamhandler not in logger.handlers:
# when used as a library, streamhandler is not added
# by default
logger.addHandler(streamhandler)

streamhandler.setFormatter(logging.Formatter(logformat))


Expand Down Expand Up @@ -545,8 +540,12 @@ def lineno(self):
match = re.match(br"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@(.*)", line)
if not match:
if not p.hunks:
warning("skipping invalid patch with no hunks for file %s" % p.source)
self.errors += 1
if p.source == b'.':
warning("SVN patch file detected, skipping changes for '.'")
else:
warning("skipping invalid patch with no hunks for file %s" % p.source)
self.errors += 1

# XXX review switch
# switch to headscan state
hunkhead = False
Expand Down Expand Up @@ -697,8 +696,8 @@ def _normalize_filenames(self):
for i,p in enumerate(self.items):
if debugmode:
debug(" patch type = " + p.type)
debug(" source = " + p.source)
debug(" target = " + p.target)
debug(" source = " + tostr(p.source))
debug(" target = " + tostr(p.target))
if p.type in (HG, GIT):
# TODO: figure out how to deal with /dev/null entries
debug("stripping a/ and b/ prefixes")
Expand Down Expand Up @@ -1162,6 +1161,12 @@ def main():
if options.debugmode:
setdebug() # this sets global debugmode variable

if streamhandler not in logger.handlers:
# when used as a library, streamhandler is not added
# by default
logger.addHandler(streamhandler)


if readstdin:
patch = PatchSet(sys.stdin)
else:
Expand Down