Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.11 removed "U" mode breaks methods like text and lines #217

Open
charlesnagy opened this issue Jun 28, 2023 · 1 comment
Open

Comments

@charlesnagy
Copy link

_textmode is set to be by default "U" in pager/deps/path3.py. "U" mode was removed in Python 3.11 so that breaks methods such as text and others where encoding is not provided.

# Universal newline support
_textmode = 'U'
if hasattr(__builtins__, 'file') and not hasattr(file, 'newlines'):
    _textmode = 'r'

# ...

    def text(self, encoding=None, errors='strict'):
        """ ... """
        if encoding is None:
            # 8-bit
            f = self.open(_textmode)

Exception:

File "/Users/karolynagy/.virtualenvs/test/lib/python3.11/site-packages/paver/deps/path3.py", line 582, in text
    f = self.open(_textmode)
        ^^^^^^^^^^^^^^^^^^^^
  File "/Users/karolynagy/.virtualenvs/test/lib/python3.11/site-packages/paver/deps/path3.py", line 539, in open
    return open(self, mode)
           ^^^^^^^^^^^^^^^^
ValueError: invalid mode: 'U'

One fix to provide encoding when calling text method works. For example:

- options.assets.js_files = map(lambda x: (str(x), x.text()), files)
+ options.assets.js_files = map(lambda x: (str(x), x.text("utf8")), files)

However it would be good if the method didn't fail without parameters.

@Almad
Copy link
Member

Almad commented Jun 29, 2023

Thank you. I believe it's probably time to #190 given the issues like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants