Patchwork py3: cast attribute name to sysstr in clearcachedproperty()

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 22, 2018, 1:49 p.m.
Message ID <475921a3028c419ab50e.1542894559@mimosa>
Download mbox | patch
Permalink /patch/36711/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 22, 2018, 1:49 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1542894022 -32400
#      Thu Nov 22 22:40:22 2018 +0900
# Node ID 475921a3028c419ab50e17f2b8855e01cb1fa35e
# Parent  0d8425311f2f3f30491f4a4604498ea643d7c25a
py3: cast attribute name to sysstr in clearcachedproperty()
Pulkit Goyal - Nov. 22, 2018, 1:59 p.m.
On Thu, Nov 22, 2018 at 4:51 PM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1542894022 -32400
> #      Thu Nov 22 22:40:22 2018 +0900
> # Node ID 475921a3028c419ab50e17f2b8855e01cb1fa35e
> # Parent  0d8425311f2f3f30491f4a4604498ea643d7c25a
> py3: cast attribute name to sysstr in clearcachedproperty()
>

I like how to you browse through code and find that this is not working on
Python 3. Queued this, many thanks!

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1535,6 +1535,7 @@  class propertycache(object):
 
 def clearcachedproperty(obj, prop):
     '''clear a cached property value, if one has been set'''
+    prop = pycompat.sysstr(prop)
     if prop in obj.__dict__:
         del obj.__dict__[prop]