Skip to content

yarl.query_var not support prepare None #1533

@IvanKirpichnikov

Description

@IvanKirpichnikov

Please confirm the following

  • I understand this is open source software provided for free and that I might not receive a timely response.
  • I am positive I am NOT reporting a (potential) security
    vulnerability, to the best of my knowledge. (These must be shared by
    submitting this report form instead, if
    any hesitation exists.)
  • I am willing to submit a pull request with reporoducers as xfailing test cases or even entire fix. (Assign this issue to me.)

Describe the bug

yarl does not support None processing in the query_var function

To Reproduce

import yarl

yarl._query.query_var(None)

Expected behavior

The function will return "null"

Logs/tracebacks

Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    yarl._query.query_var(None)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/ivank_kirpichnikov/Documents/projects/maxo/.venv/lib/python3.13/site-packages/yarl/_query.py", line 33, in query_var
    raise TypeError(
    ...<3 lines>...
    )
TypeError: Invalid variable type: value should be str, int or float, got None of type <class 'NoneType'>

Python Version

$ python --version
Python 3.13.3

multidict Version

$ python -m pip show multidict
Name: multidict
Version: 6.5.0
Location: /home/ivank_kirpichnikov/Documents/projects/maxo/.venv/lib/python3.13/site-packages
Requires:
Required-by: aiohttp, yarl

propcache Version

$ python -m pip show propcache
Name: propcache
Version: 0.3.2
Location: /home/ivank_kirpichnikov/Documents/projects/maxo/.venv/lib/python3.13/site-packages
Requires:
Required-by: aiohttp, yarl

yarl Version

$ python -m pip show yarl
Name: yarl
Version: 1.20.1
Location: /home/ivank_kirpichnikov/Documents/projects/maxo/.venv/lib/python3.13/site-packages
Requires: idna, multidict, propcache
Required-by: aiohttp

OS

Manjaro

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions