Skip to content

Test Failures in the pipeline #642

Description

Found this failure while looking into the pipelines.

https://sqlclientdrivers.visualstudio.com/public/_build/results?buildId=157865&view=logs&j=15f12f6b-5115-5c90-8b46-492e8e236788&t=c7b07bc8-4166-5494-ac4e-f321834baa1c&s=d654deb9-056d-50a2-1717-90c08683d50a

https://sqlclientdrivers.visualstudio.com/public/_build/results?buildId=157685&view=logs&j=15f12f6b-5115-5c90-8b46-492e8e236788&t=c7b07bc8-4166-5494-ac4e-f321834baa1c

Example job Run pytest with coverage in Ubuntu ARM64 container

tests/test_004_cursor.py::test_executemany_numeric_override_needed
  /opt/venv/lib/python3.10/site-packages/_pytest/unraisableexception.py:67: PytestUnraisableExceptionWarning: Exception ignored in: <function Cursor.__del__ at 0x55054afac0>
  
  Traceback (most recent call last):
    File "/workspace/mssql_python/cursor.py", line 3186, in __del__
      self.close()
    File "/workspace/mssql_python/cursor.py", line 782, in close
      if self.closed:
  AttributeError: 'Cursor' object has no attribute 'closed'. Did you mean: 'close'?
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/workspace/mssql_python/cursor.py", line 3192, in __del__
      if sys and sys._is_finalizing():
  AttributeError: module 'sys' has no attribute '_is_finalizing'. Did you mean: 'is_finalizing'?
  
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
--------- generated xml file: /workspace/test-results-Ubuntu-arm64.xml ---------

The failures are silently ignored.

Activity

  1. github-actions commented on Jun 23, 2026

    @github-actions

    Hi Saurabh Singh (@saurabh500), thank you for opening this issue!

    Our team will review it shortly. We aim to triage all new issues within 24-48 hours and get back to you.

    If you have additional information to share, please feel free to update the issue.

    Thank you for your patience!

  2. added
    bugSomething isn't working
    triage doneIssues that are triaged by dev team and are in investigation.
    and removed
    triage neededFor new issues, not triaged yet.
    on Jun 25, 2026
  3. subrata-ms commented on Jun 25, 2026

    @subrata-ms
    Contributor

    Hi Saurabh Singh (@saurabh500) , Thanks for raising the bug. I have addressed the issue under attached PR. Below is the fix summary -

    Summary:
    This pull request improves the robustness of the Cursor class initialization and cleanup logic, ensuring that partially-initialized or half-constructed cursor objects are handled safely and do not cause unraisable exceptions during garbage collection. It also adds regression tests to prevent recurrence of related bugs.

    Initialization and cleanup robustness:
    The init method in cursor.py now sets self.closed = False and self.hstmt = None as the very first statements, before any code that might raise an exception, ensuring that even partially-initialized Cursor instances have a consistent state for cleanup. [1] [2]
    The close() method now safely checks for the existence of the closed attribute using getattr(self, "closed", True), preventing AttributeError if the attribute is missing (e.g., in half-initialized objects).
    The del method now uses the correct sys.is_finalizing() function (instead of the incorrect sys._is_finalizing()) and guards logging calls to prevent unraisable exceptions during interpreter shutdown.

    Testing and regression prevention:
    Adds test_cursor_del_half_initialized_cursor_no_errors and test_cursor_init_failure_leaves_consistent_state to ensure that half-initialized cursors do not raise unraisable exceptions during garbage collection and that failed initialization leaves the cursor and connection in a consistent, recoverable state.

  4. saurabh500 commented on Jun 27, 2026

    @saurabh500
    ContributorAuthor

    Subrata (@subrata-ms) I think the more important questions is "Why did the pipeline not fail? "
    This is a problem that should be solved, to prevent any changes going in, despite failed tests.

  5. subrata-ms commented on Jul 30, 2026

    @subrata-ms
    Contributor

    Hi Saurabh Singh (@saurabh500) , the pipeline didn't catch this error because the error is a warning, not a test failure — and nothing in this repo's pytest config promotes warnings to errors.

  6. added a commit that references this issue on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workinginADOtriage doneIssues that are triaged by dev team and are in investigation.under development

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions