Ticket #4186 (closed: fixed)

Opened 9 years ago

Last modified 5 years ago

Problem with Python lhs code

Reported by: Martyn Gigg Owned by: Martyn Gigg
Priority: minor Milestone: Release 2.1
Component: Mantid Keywords:
Cc: Blocked By:
Blocking: Tester: Andrei Savici

Description

The code that deduces the names of the variables on the left-hand side of a function call has a limitation/bug.

Some types of call, eg

from mantid.simpleapi import LoadNexus

def foo(callableObj, *args, **kwargs):
    wkspace = callableObj(*args, **kwargs)
    
foo(LoadNexus, 'filename.nxs')

have the incorrect index at last_i (mantid.kernel.funcreturns.py:121) due to the call being passed through an intermediate reference. Currently this method does not provide the correct answer and throws a KeyError.

It came up in the unit tests but I don't see this as a common user case at the moment hence the priority.

Change History

comment:1 Changed 9 years ago by Owen Arnold

refs #4186. Implemented, should work for all IMDWorkspaces

Changeset: 8e71d1fa11ccaed7e1850e3d14d4c596fdc7053f

comment:2 Changed 9 years ago by Owen Arnold

Last commit should have been against ticket #4189. Apologies.

comment:3 Changed 9 years ago by Nick Draper

  • Milestone changed from Iteration 32 to Iteration 33

Moved to iteration 33 at iteration 32 code freeze

comment:4 Changed 9 years ago by Andrei Savici

The following script fails with KeyError on line 3: "34" in file 'funcreturns.py' at line 158

mykwargs={'Filename':'CNCS_7860_event.nxs'}
w=Load(Filename='CNCS_7860_event.nxs')
w1=Load(**mykwargs)

I was running it from the script window in MantidPlot

comment:5 Changed 9 years ago by Martyn Gigg

  • Status changed from new to accepted

comment:6 Changed 9 years ago by Martyn Gigg

Add 3 other bytecode operations to fix LHS code in Python. Refs #4186

There are 4 possible pieces of bytecode that are in the stack when retrieving the LHS names, we were missing the variable arg ones.

Changeset: 5424d14e43805347296739b8735a636e18437f54

comment:7 Changed 9 years ago by Martyn Gigg

  • Status changed from accepted to verify
  • Resolution set to fixed

comment:8 Changed 9 years ago by Andrei Savici

  • Status changed from verify to verifying
  • Tester set to Andrei Savici

comment:9 Changed 9 years ago by Martyn Gigg

Add 3 other bytecode operations to fix LHS code in Python. Refs #4186

There are 4 possible pieces of bytecode that are in the stack when retrieving the LHS names, we were missing the variable arg ones.

Changeset: 5424d14e43805347296739b8735a636e18437f54

comment:10 Changed 8 years ago by Andrei Savici

  • Status changed from verifying to closed

Works :)

comment:11 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 5033

Note: See TracTickets for help on using tickets.