Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions mf2py/backcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

"""

import codecs
import copy
import json
import os
Expand All @@ -47,7 +46,7 @@
for filename in os.listdir(_RULES_LOC):
file_path = os.path.join(_RULES_LOC, filename)
root = os.path.splitext(filename)[0]
with codecs.open(file_path, "r", "utf-8") as f:
with open(file_path, "r", "utf-8") as f:
Copy link
Copy Markdown

@ysamlan ysamlan Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, Python 3 open() takes encoding as a keyword argument, not positional. The third positional
parameter is buffering (expects an int), so this:

open(file_path, "r", "utf-8")

raises TypeError: 'str' object cannot be interpreted as an integer at import time on Python 3.14. Should be:

open(file_path, encoding="utf-8") ('r' is the default for mode, so that's optional).

> help(open)
Help on built-in function open in module _io:
open(
    file,
    mode='r',
    buffering=-1,
    encoding=None,
    errors=None,
    newline=None,
    closefd=True,
    opener=None
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I did not test the change back then. I have made all the optional parameters keywords.

rules = json.load(f)

_CLASSIC_MAP[root] = rules
Expand Down