Skip to content

Invalid mode 'rU' when realding SystemStatCollector.PROC_STAT_FILENAME #108

Open

Description

@vinnix

Folks, while trying to make pg_view work on my test environment I came accross the following error:

$ python pg_view.py -U postgres -h localhost -d postgres -p 5464
Traceback (most recent call last):
  File "/home/vinnix/Sources/Github/pg_view/pg_view/__init__.py", line 266, in main
    loop(collectors, consumer, groups, output_method)
  File "/home/vinnix/Sources/Github/pg_view/pg_view/__init__.py", line 87, in loop
    curses.wrapper(do_loop, groups, output_method, collectors, consumer)
  File "/home/vinnix/.pyenv/versions/3.12.9/lib/python3.12/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vinnix/Sources/Github/pg_view/pg_view/__init__.py", line 139, in do_loop
    process_single_collector(st)
  File "/home/vinnix/Sources/Github/pg_view/pg_view/utils.py", line 81, in process_single_collector
    st.refresh()
  File "/home/vinnix/Sources/Github/pg_view/pg_view/collectors/system_collector.py", line 155, in refresh
    stat_data = self._read_proc_stat()
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vinnix/Sources/Github/pg_view/pg_view/collectors/system_collector.py", line 176, in _read_proc_stat
    fp = open(SystemStatCollector.PROC_STAT_FILENAME, 'rU')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid mode: 'rU'

Activity

  1. vinnix commented on May 24, 2025

    @vinnix
    Author

    Found in this link: https://stackoverflow.com/questions/38093326/whats-the-difference-between-rb-and-ru-in-the-open-function-for-csv that
    " As the documentation states, U (Universal Newlines) mode is deprecated; you should not use it anymore. Instead use the newline= keyword argument."

    Changing 'rU' to 'r' seems to work.
    More tests are necessary to be sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions