Skip to content

BUG: urllib.* modules are never imported #4700

@yut23

Description

@yut23

Bug report

Bug summary

The urllib submodules (request, parse, etc.) are used in a few code paths, most notably the command-line interface. Importing urllib on its own does nothing, as its __init__.py is empty (see https://github.com/python/cpython/tree/3.12/Lib/urllib/). This leads to a crash if the code tries to use the modules.

Code for reproduction

$ yt download --list

Actual outcome

Traceback (most recent call last):
  File "/home/eric/mambaforge/envs/yt-devel/bin/yt", line 8, in <module>
    sys.exit(run_main())
  File "/home/eric/build/yt/yt/utilities/command_line.py", line 1613, in run_main
    args.func(args)
  File "/home/eric/build/yt/yt/utilities/command_line.py", line 223, in run
    self(args)
  File "/home/eric/build/yt/yt/utilities/command_line.py", line 1555, in __call__
    self.get_list()
  File "/home/eric/build/yt/yt/utilities/command_line.py", line 1589, in get_list
    urllib.request.urlopen("http://yt-project.org/data/datafiles.json")
AttributeError: module 'urllib' has no attribute 'request'

Expected outcome

It should list all the data files available on https://yt-project.org/data.

Version Information

  • Operating System: Linux
  • Python Version: 3.10.12
  • yt version: git main (14c49c4)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions