simon-git: putty (master): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Sat Feb 29 12:16:03 GMT 2020


TL;DR:
  db7a314c testcrypt.py: fake some OO syntax.
  809a4eb2 testcrypt.py: avoid restarting subprocess for frees.

Repository:     https://git.tartarus.org/simon/putty.git
On the web:     https://git.tartarus.org/?p=simon/putty.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2020-02-29 12:16:03

commit db7a314c3810666eec8589262431d7055ca57880
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=db7a314c3810666eec8589262431d7055ca57880;hp=e025ccc2f0bfaacc9a18d32334a2aa4617b3acc1
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Feb 29 09:48:00 2020 +0000

    testcrypt.py: fake some OO syntax.
    
    When I'm writing Python using the testcrypt API, I keep finding that I
    instinctively try to call vtable methods as if they were actual
    methods of the object. For example, calling key.sign(msg, 0) instead
    of ssh_key_sign(key, msg, 0).
    
    So this change to the Python side of the testcrypt mechanism panders
    to my inappropriate finger-macros by making them work! The idea is
    that I define a set of pairs (type, prefix), such that any function
    whose name begins with the prefix and whose first argument is of that
    type will be automatically translated into a method on the Python
    object wrapping a testcrypt value of that type. For example, any
    function of the form ssh_key_foo(val_ssh_key, other args) will
    automatically be exposed as a method key.foo(other args), simply
    because (val_ssh_key, "ssh_key_") appears in the translation table.
    
    This is particularly nice for the Python 3 REPL, which will let me
    tab-complete the right set of method names by knowing the type I'm
    trying to invoke one on. I haven't decided yet whether I want to
    switch to using it throughout cryptsuite.py.
    
    For namespace-cleanness, I've also renamed all the existing attributes
    of the Python Value class wrapper so that they start with '_', to
    leave the space of sensible names clear for the new OOish methods.

 test/testcrypt.py | 54 ++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 40 insertions(+), 14 deletions(-)

commit 809a4eb2493a9757eaab3e1e4d47ebe26457754a
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=809a4eb2493a9757eaab3e1e4d47ebe26457754a;hp=db7a314c3810666eec8589262431d7055ca57880
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Feb 29 10:54:16 2020 +0000

    testcrypt.py: avoid restarting subprocess for frees.
    
    I just ran into a bug in which the testcrypt child process was cleanly
    terminated, but at least one Python object was left lying around
    containing the identifier of a testcrypt object that had never been
    freed. On program exit, the Python reference count on that object went
    to zero, the __del__ method was invoked, and childprocess.funcall
    started a _new_ instance of testcrypt just so it could tell it to free
    the object identifier - which, of course, the new testcrypt had never
    heard of!
    
    We can already tell the difference between a ChildProcess object which
    has no subprocess because it hasn't yet been started, and one which
    has no subprocess because it's terminated: the latter has exitstatus
    set to something other than None. So now we enforce by assertion that
    we don't ever restart the child process, and the __del__ method avoids
    doing anything if the child has already finished.

 test/testcrypt.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)



More information about the tartarus-commits mailing list