-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Coverity scan: copy/paste error in Lib/xml/dom/minidom.py #79233
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
Comments
Analyzing some coverity scan results I stumbled upon this issue: Python-3.6.5/Lib/xml/dom/minidom.py:1914: original: "n._call_user_data_handler(operation, n, notation)" looks like the original copy. It seems that the warning is indeed a bug, and the code in question was basically merged into python from pyxml 16 years ago. |
Agree, this looks like a bug. Do you mind to create a PR Charalampos? |
Hey, |
Hello Shivank. I had a PR ready locally which I was about to push, so you posted just at the right time :) Feel free to work on this issue. |
Thanks, Charalampos :) 1924--> n._call_user_data_handler(operation, n, entity) |
*1924--> n._call_user_data_handler(operation, n, notation) |
You need also to write a test. |
Oh, I see, so I believe that's where my learning of CPython is going to start. |
|
The test code should fail with the current, unfixed code, due to the bug described here. You will need to:
After you've done this, you'll have something ready to be a PR. It will likely still require some work, e.g. cleaning up the code, adding/improving comments, conforming to our code style guidelines, and adding a NEWS entry. However, since this will be one of your first PRs, I suggest first just posting your test and fix as a PR. Note that creating a PR will also trigger the test suite to be automatically run on several platforms; after ~15 minutes take a look at the results, and if there are any failures you should address them ASAP. |
now when I am running test_minidom.py for both 1,2 I am receiving the same following result. FAIL: testRemoveAttributeNode (main.MinidomTest) Traceback (most recent call last):
File "test_minidom.py", line 328, in testRemoveAttributeNode
self.assertIs(node, child.removeAttributeNode(node))
AssertionError: <xml.dom.minidom.Attr object at 0x7fc62ab662a0> is not None Ran 120 tests in 0.048s FAILED (failures=1) |
Shivank, your last comment is unclear. Are you asking a question or just reporting some progress? |
Oh Sorry, it was like was more like a question. should i first try solve for this error? or maybe i haven't understood what type of test function i need to write. |
Shivank, there is currently technically no "error to solve", since we have no test that causes this erroneous behavior and catches it. We've only found what appears to be a bug by looking at the code, but we need to *verify* that it is indeed a bug. Also, this means that we have a piece of code that our test suite is missing; this is the real reason I insist that this needs a test. You should trace what uses the affected code and which scenarios could lead to this bug causing unexpected behavior. In this case, the code is in |
Looking at the code in Lib/xml/dom/minidom.py, this exact typo is also found in DocumentType.cloneNode(). That should be tested and fixed too. |
Shivank, I recommend taking a look at some of the existing tests for this module, found in Lib/test/test_minidom.py. See how they are built and how various functionality is tested. This should give you a good idea of what a test for this bug would look like. |
I See, I need to find out for what test case |
Shivank, indeed it seems you're now in the right direction. A bit of clarification:
|
I just want to update that i was not able to work more in last two days as i was busy in some personal work. now i am on it and will update something soon. Sorry for delay :) |
Hey Tal, I am extremely sorry for all delay. actually, due to internship and my university exams, I am unable to dedicate my time to bug(bpo-35052). please consider it and you can tell Charalampos Stratakis in the bug to push his prepared pull request. |
Ah, XML is such an overengineered format! I usually live with the standard HTML entities – but it turns out you can define your own! Here's a reproducer which shows how to do that. |
The bug was introduced in 2003 by: commit 787354c
|
I wrote a fix: PR 11061. |
Thanks for the bug report and proposed fix Charalampos Stratakis, thanks for the reproducer script Petr Viktorin. Shivank Gautam:
No problem. Charalampos Stratakis told me that he wanted to see this bug fixed to reduce the number of issues spotted by Coverity, so I fixed it. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: