[issue41770] Import module doesn't updated

2020-09-18 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I carefully redid your test, corrected, 3 times, and it works as expected.
Win 10, 3.9.0rc2.  

>>> import a.tem3 as t
>>> t.b
Traceback (most recent call last):
  File "", line 1, in 
t.b
AttributeError: module 'a.tem3' has no attribute 'b'

# Add 'b = 2' to a/tem3.py and save.

>>> import sys
>>> del sys.modules['a.tem3']
>>> import a.tem3 as t
>>> t.b
2

Without seeing exactly what you did and when, I can only guess that you 
imported a version of xxx without the 'b' binding.  I once added it but *forgot 
to save* before re-importing.  Note that dictionary deletion and importing are 
well tested operations, so that bugs in normal imports are very unlikely.  If 
you really get a failure, there must be some relevant details that you have 
omitted, like importing from a remote system that is locally cached, with the 
local cache unchanged by editing the remote original.  Or having an OS bug such 
that saving a file does not update the 'last changed' time. 

If you disagree with a closing, please request re-opening and give us a chance 
to reproduce and discuss first rather than doing so yourself.

--
nosy: +terry.reedy -paul.moore, steve.dower, tim.golden, zach.ware
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41770] Import module doesn't updated

2020-09-12 Thread chen-y0y0


chen-y0y0  added the comment:

--REOPEN--
>>> # I try:
>>> import xxx
>>> del sys.modules['xxx']
>>> # But:
Traceback (most recent call last):
  File "", line 1, in 
del sys.modules['xxx']
NameError: name 'sys' is not found
>>> # I try to import sys.
>>> import sys
>>> del sys.modules['xxx']
>>> import xxx
>>> xxx.b
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: module 'xxx' has no attribute 'b'

--
resolution: not a bug -> 
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41770] Import module doesn't updated

2020-09-11 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

This is not a bug, it is working as designed. Importing takes the module from 
the cache. You can either delete the module from the cache:

del sys.modules['modulename']
import modulename  # reloads from the module file


or possibly simpler, use reload:

importlib.reload(modulename)

--
components: +Interpreter Core -Windows
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type: resource usage -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41770] Import module doesn't updated

2020-09-11 Thread pmp-p


Change by pmp-p :


--
nosy:  -pmpp

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41770] Import module doesn't updated

2020-09-11 Thread pmp-p


pmp-p  added the comment:

Hi, you just need to call del sys.modules['xxx'] and have a look at 
https://docs.python.org/3.7/library/importlib.html#importlib.invalidate_caches 

before importing again

--
nosy: +pmpp

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41770] Import module doesn't updated

2020-09-11 Thread chen-y0y0


New submission from chen-y0y0 :

# I create a module:
# \sys.path\xxx.py
a = 9
# And:
>>> import xxx
>>> xxx.a
9
# I delete this imported module and modified this module:
del xxx
# \sys.path\xxx.py
a = 9
b = 8
# And re-import:
>>> import xxx
>>> xxx.b
# But:
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: type object 'xxx' has no attribute 'b'

--
components: Windows
messages: 376766
nosy: paul.moore, prasechen, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Import  module doesn't updated
type: resource usage
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com