<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - Error on creating script provider for Python script from location=document"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=122545">122545</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Error on creating script provider for Python script from location=document
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.1.4.2 release
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Calc
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>spinnau@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Description:
When opening a Calc document with a user-defined function that calls some
Python code from location=document, the following error message will be shown:

BASIC runtime error.
An exception occurred
Type: com.sun.star.script.provider.ScriptFrameworkErrorException
Message: ProviderCache::createProvider() Error creating provider from
factory. <class 'KeyError'>: 'document’, traceback follows
  File "/usr/lib/libreoffice/program/unohelper.py”, line 295, in
createInstanceWithArgumentsAndContext
  return self.clazz(context, *args)
File "/usr/lib/libreoffice/program/pythonscript.py”, line 999, in __init__
  raise e
File "/usr/lib/libreoffice/program/pythonscript.py”, line 975, in __init__
  urlHelper = MyUriHelper(ctx, storageType)
File "/usr/lib/libreoffice/program/pythonscript.py”, line 189, in __init__
  self.m_baseUri = expandUri(self.s_UriMap[location])


I have attached a sample document "HelloWorld.ods" with a minimal Python hello
world function, that is wrapped with a BASIC macro as a user-defined function.
This Calc document works fine with LibreOffice version up to 6.1.3.2. Newer
versions show the error message as described above when the file is opened.
Tested versions that are affected from this bug:

* 6.1.4.2 (Arch Linux 64 bit)
* 6.1.4.2 (Windows 32 bit)
* 6.2.0.1 (Linux 64 bit AppImage)
* 6.3.0.0.alpha0_2018-12-29 (Linux 64 bit AppImage)

Steps to Reproduce:
1. Allow execution of macros (changing "Macro Security" setting to "Medium")
2. Open the attached document "HelloWorld.ods"
3. Select "Enable Macros"

Actual Results:
The error message described above will be shown. The =HELLOWORLD() function in
cell "B3" is not evaluated.

Expected Results:
The formula in cell "B3" should evaluate to "Hello world".


Reproducible: Always


User Profile Reset: Yes



Additional Info:</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>