Patchwork [hglib,v2] client: ignore close() on non-open clients (issue5751)

login
register
mail settings
Submitter Gábor Stefanik
Date Feb. 14, 2018, 2:11 p.m.
Message ID <b5d05859a5d7956024b1.1518617493@GSTEFANIK.NavnGo.local>
Download mbox | patch
Permalink /patch/27931/
State Accepted
Headers show

Comments

Gábor Stefanik - Feb. 14, 2018, 2:11 p.m.
# HG changeset patch
# User Gábor Stefanik <gabor.stefanik@nng.com>
# Date 1518443649 -3600
#      Mon Feb 12 14:54:09 2018 +0100
# Node ID b5d05859a5d7956024b169dd7fe53a6ea45a4d67
# Parent  1085c904d8c04d51c6897027fe9c7bae0964b64b
client: ignore close() on non-open clients (issue5751)

Closing a client twice currently triggers a rather confusing exception.
Instead, follow the convention set by Python's file objects, and ignore close()
commands on non-open clients.

________________________________
 This message, including its attachments, is confidential and the property of NNG Llc. For more information please read NNG's email policy here:
https://www.nng.com/email-policy/
By responding to this email you accept the email policy.
Yuya Nishihara - Feb. 15, 2018, 12:12 p.m.
On Wed, 14 Feb 2018 15:11:33 +0100, Gábor Stefanik wrote:
> # HG changeset patch
> # User Gábor Stefanik <gabor.stefanik@nng.com>
> # Date 1518443649 -3600
> #      Mon Feb 12 14:54:09 2018 +0100
> # Node ID b5d05859a5d7956024b169dd7fe53a6ea45a4d67
> # Parent  1085c904d8c04d51c6897027fe9c7bae0964b64b
> client: ignore close() on non-open clients (issue5751)

Looks good to me, thanks.
Augie Fackler - Feb. 15, 2018, 3:23 p.m.
queued for hglib, thanks for the review Yuya!

> On Feb 15, 2018, at 07:12, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> On Wed, 14 Feb 2018 15:11:33 +0100, Gábor Stefanik wrote:
>> # HG changeset patch
>> # User Gábor Stefanik <gabor.stefanik@nng.com>
>> # Date 1518443649 -3600
>> #      Mon Feb 12 14:54:09 2018 +0100
>> # Node ID b5d05859a5d7956024b169dd7fe53a6ea45a4d67
>> # Parent  1085c904d8c04d51c6897027fe9c7bae0964b64b
>> client: ignore close() on non-open clients (issue5751)
> 
> Looks good to me, thanks.

Patch

diff -r 1085c904d8c0 -r b5d05859a5d7 hglib/client.py

--- a/hglib/client.py   Thu Feb 01 15:10:02 2018 -0500

+++ b/hglib/client.py   Mon Feb 12 14:54:09 2018 +0100

@@ -291,6 +291,8 @@ 

         Attempting to call any function afterwards that needs to
         communicate with the server will raise a ValueError.
         """
+        if not self.server:

+            return 0

         return self._close()[0]

     def _close(self):