Menu

#8 PythonEngine.ImportModule Fails On Multiple Dots in Filename

closed
nobody
None
5
2010-10-08
2007-07-24
vpiattelli
No

If you use PythonEngine.ImportModule on a file that contains multiple dots in its name (for example test.one.py), the ImportModule statement will fail and return null.

Discussion

  • Barton Cline

    Barton Cline - 2010-09-12

    Embedded UnitTest is sadly lacking at the moment. I'll add pyimport.cs to the EmbeddingTest project with the understanding that this may open a whole new can of worms...
    - Barton

     
  • Barton Cline

    Barton Cline - 2010-09-12

    This works against the alpha-2 release:

    /// <summary>
    /// Test subdirectory import
    /// </summary>
    /// <remarks>
    /// Requires the directory structure to exist where python will find it.
    /// (I used
    /// site-packages/ to contain the tree:)
    /// dotnet/
    /// __init__.py
    /// test/
    /// __init__.py
    /// one.py
    /// </remarks>
    [Test]
    public void TestDottedName()
    {
    PyObject module;
    module = PythonEngine.ImportModule("dotnet.test.one");
    Assert.IsNotNull(module, ">>> import dotnet.test.one # FAILED");
    }

     
  • vpiattelli

    vpiattelli - 2010-09-14

    Glad to see this get fixed. Thank you!

     
  • Barton Cline

    Barton Cline - 2010-10-08

    This is most likely a red herring: The original post gives a hint that vpiattelli didn't quite have have a handle on python import semantics "(for example test.one.py)"' leaving the extension in place. But it was a great excuse to tear into the UnitTest classes and play around. I've uploaded the results onto the trunk.

     
  • Barton Cline

    Barton Cline - 2010-10-08
    • status: open --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.