Patchwork [1,of,2] py3: open file in rb mode

login
register
mail settings
Submitter Rishabh Madan
Date March 15, 2017, 9:35 a.m.
Message ID <1ada79790380d3f9e416.1489570510@bunty>
Download mbox | patch
Permalink /patch/19359/
State Accepted
Headers show

Comments

Rishabh Madan - March 15, 2017, 9:35 a.m.
# HG changeset patch
# User Rishabh Madan <rishabhmadan96@gmail.com>
# Date 1489569678 -19800
#      Wed Mar 15 14:51:18 2017 +0530
# Node ID 1ada79790380d3f9e416780f6447b383cc18f817
# Parent  1c48a8278b2f015fca607dfc652823560a5ac580
py3: open file in rb mode
Yuya Nishihara - March 15, 2017, 1:05 p.m.
On Wed, 15 Mar 2017 15:05:10 +0530, Rishabh Madan wrote:
> # HG changeset patch
> # User Rishabh Madan <rishabhmadan96@gmail.com>
> # Date 1489569678 -19800
> #      Wed Mar 15 14:51:18 2017 +0530
> # Node ID 1ada79790380d3f9e416780f6447b383cc18f817
> # Parent  1c48a8278b2f015fca607dfc652823560a5ac580
> py3: open file in rb mode
> 
> diff -r 1c48a8278b2f -r 1ada79790380 mercurial/match.py
> --- a/mercurial/match.py	Sun Mar 12 17:16:43 2017 -0700
> +++ b/mercurial/match.py	Wed Mar 15 14:51:18 2017 +0530
> @@ -740,7 +740,7 @@
>      syntax = 'relre:'
>      patterns = []
>  
> -    fp = open(filepath)
> +    fp = open(filepath, 'rb')
>      for lineno, line in enumerate(util.iterfile(fp), start=1):
>          if "#" in line:
>              global _commentre

Since we do line.rstrip(), this should be fine. Queued the first patch,
thanks.

Patch

diff -r 1c48a8278b2f -r 1ada79790380 mercurial/match.py
--- a/mercurial/match.py	Sun Mar 12 17:16:43 2017 -0700
+++ b/mercurial/match.py	Wed Mar 15 14:51:18 2017 +0530
@@ -740,7 +740,7 @@ 
     syntax = 'relre:'
     patterns = []
 
-    fp = open(filepath)
+    fp = open(filepath, 'rb')
     for lineno, line in enumerate(util.iterfile(fp), start=1):
         if "#" in line:
             global _commentre