New submission from Segev Finer <segev...@gmail.com>:

With the file hello/__init__.py:

    ham = 123
    spam()spam()

I get the following:

    Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 
bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import hello
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "hello\__init__.py", line 2
        spam()spam()
                 ^
    SyntaxError: invalid syntax
    >>> import hello
    >>> print hello
    <module 'hello' from 'hello'>
    >>> print dir(hello)
    ['__doc__', '__file__', '__name__', '__package__', '__path__']
    >>>

I'd expect to get the SyntaxError twice, which is indeed what happens on at 
least Python 3.6 (Possibly earlier Python 3 versions).

Originally found here https://github.com/pallets/flask/issues/2423 & 
https://github.com/pallets/flask/pull/2588

I'm going to submit a PR with a fix.

----------
components: Interpreter Core
messages: 309736
nosy: Segev Finer
priority: normal
severity: normal
status: open
title: Python 2.7 leaks a packages __init__.py module object on SyntaxError
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32524>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to