Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with list in Python 3.8.5 #88242

Closed
becky07 mannequin opened this issue May 8, 2021 · 23 comments
Closed

issue with list in Python 3.8.5 #88242

becky07 mannequin opened this issue May 8, 2021 · 23 comments
Labels
3.8 only security fixes OS-windows topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@becky07
Copy link
Mannequin

becky07 mannequin commented May 8, 2021

BPO 44076
Nosy @pfmoore, @tiran, @tjguk, @stevendaprano, @zware, @zooba, @akulakov, @shreyanavigyan
Files
  • Issue in Tkinter with Python 2.pdf: example of screen and issue
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-05-10.15:25:36.244>
    created_at = <Date 2021-05-08.13:04:43.979>
    labels = ['3.8', 'invalid', 'type-bug', 'expert-tkinter', 'OS-windows']
    title = 'issue with list in Python 3.8.5'
    updated_at = <Date 2021-05-10.15:25:36.243>
    user = 'https://bugs.python.org/becky07'

    bugs.python.org fields:

    activity = <Date 2021-05-10.15:25:36.243>
    actor = 'zach.ware'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-05-10.15:25:36.244>
    closer = 'zach.ware'
    components = ['Tkinter', 'Windows']
    creation = <Date 2021-05-08.13:04:43.979>
    creator = 'becky07'
    dependencies = []
    files = ['50030']
    hgrepos = []
    issue_num = 44076
    keywords = []
    message_count = 23.0
    messages = ['393256', '393257', '393260', '393266', '393287', '393311', '393325', '393340', '393341', '393343', '393344', '393345', '393353', '393355', '393357', '393358', '393359', '393360', '393361', '393362', '393370', '393371', '393408']
    nosy_count = 9.0
    nosy_names = ['paul.moore', 'christian.heimes', 'tim.golden', 'steven.daprano', 'zach.ware', 'steve.dower', 'andrei.avk', 'shreyanavigyan', 'becky07']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue44076'
    versions = ['Python 3.8']

    @becky07
    Copy link
    Mannequin Author

    becky07 mannequin commented May 8, 2021

    I am using Python under Windows 10 on Dell for a log time.
    All of my applications on Python were working fine.
    Suddenly from the beginning of May,
    My apps do not update a "list" data after a new insert,
    even with small data volume.

    As well as choosing old data from a list,
    a message appears stating that the identifier is out of range,
    and is working properly after restart.
    Programs that do not use a list work fine.

    After investigation, it appears memory issues.
    How I solve the issue?

    @becky07 becky07 mannequin added type-feature A feature request or enhancement 3.8 only security fixes OS-windows labels May 8, 2021
    @becky07
    Copy link
    Mannequin Author

    becky07 mannequin commented May 8, 2021

    I'm using tkinter 8.6 with Python

    @shreyanavigyan
    Copy link
    Mannequin

    shreyanavigyan mannequin commented May 8, 2021

    Can you show an example code where this occurs? Which Python 3.8 subversion are you using? How do you conclude these are memory issues?

    @stevendaprano
    Copy link
    Member

    I doubt it is a memory issue. Tell us what investigation you did that lead you to that conclusion.

    Python code doesn't normally just stop working for no reason. I expect that you changed your code in some way and introduced a bug.

    This is not a help desk for debugging your own code. If you need help with that, I recommend Reddit's r/learnpython, StackOverflow, or the Python-List mailing list.

    If you still think that this is a bug in Python, not in your own code, please show us the smallest program you can that demonstrates the problem:

    • what you did
    • the result you expected
    • the result that you actually got

    For example, try this:

        L = [1, 2, 3]
        L.insert(0, 999)
        print(L)
        # you should get [999, 1, 2, 3]

    If you get that result, your Python is working fine and the bug is in your code.

    @becky07
    Copy link
    Mannequin Author

    becky07 mannequin commented May 8, 2021

    I'm using tkinter for a long time, my application was running fine till 1st May, and suddenly happen this issue.

    After adding a new data to a list, it showing in some places of tkinter components. For example, in treeview, it shows based on running specfic function, but on click it appear this message:

    Traceback (most recent call last):
      File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
        return self.func(*args)
      File "xxxxxxx.py", line 1423, in OnDoubleClick
        itemXid = assetinfo_lst[xrec][1]
    IndexError: list index out of range

    in OnDoubleClick:
    xrec = self.treedata.selection()[0]
    xrec = int(xrec[1:], 16) - 1

        itemXid = assetinfo_lst[xrec][1]

    However, after exiting the program and restarting it, it is working properly.

    it could be the mainloop is not working:
    if __name__ == "__main__":
    root = Tk()
    App = MasterApp(root)
    root.mainloop()

    Is an issue with a new update of Windows 10? MS suggest to reinstall tkinter and recover Windows

    @becky07
    Copy link
    Mannequin Author

    becky07 mannequin commented May 9, 2021

    I tried the following method:

        class MasterApp(object):
            def __init__(self, root):
            ....
    
            def fun_astinfo_add(self):
    	    ...
    	    assetinfo_lst.append(lst_values)
    	    ...
    	    MasterApp(root)
        ...
    if __name__ == "__main__":
        root = Tk()
        App = MasterApp(root)
        root.mainloop()
    

    The program works properly, but the screen disappears and then reappears. Which means, that mainloop() works in the first time,
    and when there is any change in the data, it does not work.

    Reinstalling Tkinter is the right solution? Will it work?

    @akulakov
    Copy link
    Contributor

    akulakov commented May 9, 2021

    Hi Mohamed, you can try changing the following line:

        itemXid = assetinfo_lst[xrec][1]

    to:

    print('xrec',xrec)
    itemXid = assetinfo_lst[xrec]
    itemXid = itemXid[1]

    This will show you if the index error is caused by xrec or by [1] lookup. If caused by xrec lookup, you will see what xrec value is at this point.

    @becky07
    Copy link
    Mannequin Author

    becky07 mannequin commented May 9, 2021

    I made changes but result is same:

        xrec = self.treedata.selection()[0]
        xrec = int(xrec[1:], 16) - 1
    
        print('xrec: ', xrec)
        itemXid = assetinfo_lst[xrec]
        itemXid = itemXid[1]
        Exception in Tkinter callback
        Traceback (most recent call last):
        File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
            return self.func(*args)
        File "xxxxxx.py", line 1463, in OnDoubleClick
        itemXid = assetinfo_lst[xrec]
        IndexError: list index out of range
    length of assetinfo_lst before a new insert: 16
    length of assetinfo_lst after a new insert: 17
    xrec:  xrec:  28
    

    As I mentioned, It seems that the recent update of Windows has affected Tkinter,
    so that mainloop is not working after the first time

    @akulakov
    Copy link
    Contributor

    akulakov commented May 9, 2021

    Hi Mohamed,

    From the output it looks like the app is trying to get item at index 28
    from assetinfo_list, while that list is of only 17 length. So it seems
    likely that either app is not inserting enough items into assetinfo_list,
    or you are clicking on treedata.selection at a higher item than there are
    assets for in the list, or something is going wrong with associating click
    with the selection number.

    To get further help, I think you will need to create a minimal runnable
    example that shows the issue and upload it here.

    @becky07
    Copy link
    Mannequin Author

    becky07 mannequin commented May 9, 2021

    Please find attached, the demo with dummy data. As I mentioned, it was working fine until May 1st.
    Also, As I mentioned, in case I call MasterApp at the end of add function data appears correctly. This means a malfunction occurred after Windows Update, and it relates to mainloop

        class MasterApp(object):
            def __init__(self, root):
            ....
    
            def fun_astinfo_add(self):
    	    ...
    	    assetinfo_lst.append(lst_values)
    	    ...
    	    MasterApp(root)
        ...
    if __name__ == "__main__":
        root = Tk()
        App = MasterApp(root)
        root.mainloop()
    

    @stevendaprano
    Copy link
    Member

    On Sun, May 09, 2021 at 10:04:29PM +0000, Mohamed wrote:

    As I mentioned, It seems that the recent update of Windows has affected Tkinter,
    so that mainloop is not working after the first time

    That isn't what it looks like to me. If updating Windows had affected
    Tkinter, IDLE would no longer work and there would be thousands of
    people affected. I see no sign that this is the case:

    https://duckduckgo.com/?q=latest+update+of+windows+breaks+tkinter

    It would be very, very suprising if you were the only person who has
    noticed that a Windows update broke Tkinter.

    Mohamed, you said that you had done an investigation which showed memory
    corruption. What is your evidence for memory corruption?

    So far there is no evidence for a bug in Tkinter or Python. This is not
    a help desk. There are many forums where you can get help debugging your
    program, you should create a minimal example and ask for help at

    https://www.reddit.com/r/learnpython/

    http://mail.python.org/mailman/listinfo/python-list

    news:comp.lang.python

    https://discuss.python.org/c/users/7

    https://www.python.org/community/irc/

    No matter which forum you go to, you will be asked for a minimal example
    demonstrating the problem:

    http://www.sscce.org/

    https://stackoverflow.com/help/minimal-reproducible-example

    https://ericlippert.com/2014/03/05/how-to-debug-small-programs/

    https://medium.com/swlh/how-to-ask-smart-questions-d02f053a02ac

    http://www.catb.org/esr/faqs/smart-questions.html

    Note that a minimal program **MUST** be runnable. There is no point just
    deleting lines of code and replacing them with "...", because the code
    won't run.

    @stevendaprano
    Copy link
    Member

    On Sun, May 09, 2021 at 11:55:56PM +0000, Mohamed wrote:

    Please find attached, the demo with dummy data. As I mentioned, it was working fine until May 1st.

    If it was working fine until May 1st, I would start my investigation by
    looking at what changes where made to the source code on April 29, 30
    and May 1st.

    Is your source code in a source control repository? Can you compare it
    to a backup?

    Also, As I mentioned, in case I call MasterApp at the end of add
    function data appears correctly. This means a malfunction occurred
    after Windows Update, and it relates to mainloop

    Your traceback involves a keyerror and an index error. What makes you
    think this is a problem with the Tkinter mainloop rather than your own
    code?

    You are trying to delete a module from sys.modules:

    del sys.modules['cm_asset_add']
    

    (why?) but the key is not found. That exception is then caught and
    another exception raised.

    It really looks to me that your callback function fun_asset_current is
    buggy. Why is it messing with sys.modules?

    class MasterApp(object):
        def \_\_init__(self, root):
        ....
    
        def fun_astinfo_add(self):
      ...
      assetinfo_lst.append(lst_values)
      ...
      MasterApp(root)
    

    I'm not an expert at tkinter, but creating a new MasterApp object
    every single time you call the fun_astinfo_add method doesn't look
    right to me -- especially since you create that object, but then
    immediately discard it and it is instantly garbage collected.

    @shreyanavigyan
    Copy link
    Mannequin

    shreyanavigyan mannequin commented May 10, 2021

    It doesn't seem to be a Python bug at all. This is pretty awkward that even without upgrading your Python your program is breaking. I don't know tkinter well but upgrading your Windows shouldn't affect tkinter at all. And as Steven described if that was the case IDLE wouldn't work and there would lot's of reports and issues like this.

    @becky07
    Copy link
    Mannequin Author

    becky07 mannequin commented May 10, 2021

    This statement in the main program which is calling a subprogram, to control for multiple runs. Even I close this statement, the issue is same.
    del sys.modules['cm_asset_add']

    I've contacted Microsoft support team, they have different opinions, about the impact of the latest Windows update which was on May 1st

    @becky07
    Copy link
    Mannequin Author

    becky07 mannequin commented May 10, 2021

    I chose Python to develop a huge information system.
    I completed about 47%, and made a demonstration, so everything was working correctly, as evidenced by presence of the data
    Now, I can't go back, and I can't move forward

    @shreyanavigyan
    Copy link
    Mannequin

    shreyanavigyan mannequin commented May 10, 2021

    Are they saying this error is result of Windows update? (It may be. I didn't notice you're talking about 21H1, I thought you're talking about other patch updates.)

    @tiran
    Copy link
    Member

    tiran commented May 10, 2021

    For your information Python 3.8 is now in security fix-only mode and no longer receives regular updates. That means that any potential compatibility issues with Windows updates will not be addressed. Could you please update to Python 3.9 and try again?

    @becky07
    Copy link
    Mannequin Author

    becky07 mannequin commented May 10, 2021

    These are the latest updates:
    May 08, 2021, Microsoft Edge
    May 06, 2021, Microsoft OneDrive
    May 01, 2021, Update Health Tools

    There is no an option to uninstall the following:
    May 01, 2021-KB4023057: Update for Windows 10 Update Service components
    April 28, 2021—KB5001391 (OS Builds 19041.964 and 19042.964) Preview

    I don't know, any of these updates might have an effect.

    I'm using a lot of modules, it means I have to install them again on Python 3.9

    @shreyanavigyan
    Copy link
    Mannequin

    shreyanavigyan mannequin commented May 10, 2021

    Shortcut is store the output of pip in a file using,

    pip freeze > file.txt

    And then after installing Python 3.9

    py -3.9 -m pip install -m file.txt

    @becky07
    Copy link
    Mannequin Author

    becky07 mannequin commented May 10, 2021

    Thanks a lot

    @shreyanavigyan
    Copy link
    Mannequin

    shreyanavigyan mannequin commented May 10, 2021

    Today the nosy list is not working. When I don't even mean to add or remove someone, that person is automatically being added.

    @shreyanavigyan
    Copy link
    Mannequin

    shreyanavigyan mannequin commented May 10, 2021

    Sorry, for the disturbance in the nosy list but it's glitching.

    @zware
    Copy link
    Member

    zware commented May 10, 2021

    Given that 3.8 is in security-fix-only mode and that it's not clear that this is actually a Python bug, I'm closing the issue.

    If you can reproduce the issue in Python 3.9 with a short script, do please open a new issue (or reopen this one) with the reproducer and a description of what's going wrong. In the meantime, please see either the python-list@python.org mailing list or the Users category of discuss.python.org for community support for using Tkinter.

    @zware zware closed this as completed May 10, 2021
    @zware zware added invalid type-bug An unexpected behavior, bug, or error topic-tkinter and removed type-feature A feature request or enhancement labels May 10, 2021
    @zware zware closed this as completed May 10, 2021
    @zware zware added invalid type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels May 10, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes OS-windows topic-tkinter type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants