Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-4407

Issue loading the dns.resolver module with pymongo 4.7.0

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.7.1
    • Affects Version/s: None
    • Component/s: None
    • None
    • Python Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Detailed steps to reproduce the problem?

      The email-validator.validate_email (https://github.com/JoshData/python-email-validator/blob/main/email_validator/validate_email.py) call is failing after the pymongo update to 4.7.0.

      When we debugged the cause for this we found out that there is an issue in loading "dns.resolver" module.

      You can easily reproduce in REPL.

      Below code gives the error "

      AttributeError: module 'dns' has no attribute 'resolver'"

       

      from pymongo.database import Database
      import dns.resolver
      dns_resolver = dns.resolver.get_default_resolver()
      

       

      Where as below code works fine

       

      import dns.resolver
      dns_resolver = dns.resolver.get_default_resolver()
      

       

      Even this code works fine (Here we imported pymongo after dns import)

       

      import dns.resolver
      from pymongo.database import Database
      dns_resolver = dns.resolver.get_default_resolver()
      

       

      Definition of done: what must be done to consider the task complete?

      The below code must pass without any error

       

      from pymongo.database import Database
      import dns.resolver
      dns_resolver = dns.resolver.get_default_resolver()
      

       

      The exact Python version used, with patch level:

      $ python -c "import sys; print(sys.version)"

      3.12.2 (main, Feb  6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)]

      The exact version of PyMongo used, with patch level:

      $ python -c "import pymongo; print(pymongo.version); print(pymongo.has_c())"

      4.7.0

      True

      Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.

      The operating system and version (e.g. Windows 7, OSX 10.8, ...)

      Web framework or asynchronous network library used, if any, with version (e.g. Django 1.7, mod_wsgi 4.3.0, gevent 1.0.1, Tornado 4.0.2, ...)

      Security Vulnerabilities

      If you’ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here

            Assignee:
            steve.silvester@mongodb.com Steve Silvester
            Reporter:
            kiran.ms@newpage.io Kiran M S
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: