This project has moved and is read-only. For the latest updates, please go here.
1

Closed

import cElementTree fails with PTVS

description

Hi,
This may well not be a PTVS error, but I can't figure out what else it could be.

When executing my Django project from VS from visual studio 15, the command
   from xml.etree import cElementTree
throws an exception. This is discussed here: https://pytools.codeplex.com/workitem/2077. Based on the number of upvotes and the related discussion, this seems to be pretty easy to reproduce and not specific to my project. I understand that PTVS can't figure out that the exception is actually caught down the road and signals it to the user. That's ok.

The thing is that
     from xml.etree import cElementTree 
should not leave in the first place! cElementTree is part of the standard Python distro and it's definitely available in my environment. (Python 2.7)

I am providing a simple bottle project to reproduce. It's just the bottle template, where I added the import commands in the file routes.py .
If the import is called from the global context (line 10 of routes.py), it will throw.
If I delay the import to a later phase, for example moving it inside the function home(), line 15 of routes.py, the import will be sucessful.
     def home():
        """Renders the home page."""
        # Loading cElementTree succeeds, if called here.
        from xml.etree import cElementTree 
Would it be possible that PTVS or the VS debugger would interfere with the import process if the cElementtree is imported early when the project is launched?

cElementtree represents a significant performance boost versus it's pure Python sibling, would be nice to be able to use it in a PTVS environment.

file attachments

Closed Dec 14, 2015 at 6:27 PM by crwilcox

comments

blelem wrote Aug 14, 2015 at 11:18 AM

Oops. I didn't noticed that codeplex wasn't used anymore for issues reporting.
I cloned this bug to github: https://github.com/Microsoft/PTVS/issues/756