Skip to content

Domain not handle None object #143

@reahaas

Description

@reahaas

validators None issue:

code:

def validator_test():
    import validators
    if validators.domain(None):
        print("None object is FQDN")
    else:
        print("None object is NOT FQDN")

error

Traceback (most recent call last):
  File "/home/vagrant/scadafence/rea-helper.py", line 49, in <module>
    main()
  File "/home/vagrant/scadafence/rea-helper.py", line 45, in main
    validator_test()
  File "/home/vagrant/scadafence/rea-helper.py", line 33, in validator_test
    if validators.domain(None):
  File "</home/vagrant/scadafence/venv/local/lib/python2.7/site-packages/decorator.pyc:decorator-gen-2>", line 2, in domain
  File "/home/vagrant/scadafence/venv/local/lib/python2.7/site-packages/validators/utils.py", line 83, in wrapper
    value = func(*args, **kwargs)
  File "/home/vagrant/scadafence/venv/local/lib/python2.7/site-packages/validators/domain.py", line 60, in domain
    return pattern.match(to_unicode(value).encode('idna').decode('ascii'))
AttributeError: 'NoneType' object has no attribute 'encode'

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixIssue: Out of scope

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions