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.12 config parser error #119

Open
ece-mohammad opened this issue Oct 11, 2023 · 0 comments
Open

Python 3.12 config parser error #119

ece-mohammad opened this issue Oct 11, 2023 · 0 comments

Comments

@ece-mohammad
Copy link
Contributor

Error:

  • Python version: 3.12
Traceback (most recent call last):
  File "/home/pegasus/.pyenv/versions/jinja2-3.12/bin/jinja2", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/pegasus/Projects/jinja2cli/jinja2cli/cli.py", line 476, in main
    sys.exit(cli(opts, args))
             ^^^^^^^^^^^^^^^
  File "/home/pegasus/Projects/jinja2cli/jinja2cli/cli.py", line 330, in cli
    data = fn(data) or {}
           ^^^^^^^^
  File "/home/pegasus/Projects/jinja2cli/jinja2cli/cli.py", line 134, in _parse_ini
    p.readfp(StringIO(data))
    ^^^^^^^^
AttributeError: 'MyConfigParser' object has no attribute 'readfp'. Did you mean: 'read'?

Reproduction steps:

  1. Install jinja2-cli in a virtualenv
gh repo clone mattrobenolt/jinja2-cli jinja2cli && cd jinja2cli
python -m virtualen .venv
source .venv/bin/activate
pip install -e .
  1. create a ini data file and a template:
  • data.ini file:
[data]
foo=bar
ham=spam
  • template.j2 file:
## Data:

- foo: {{ data.foo }}
- bar: {{ data.bar }}
  1. run the commands:
jinja2 ./data.ini ./template.j2

According to Python 3.12 documentation, ConfigParser.read_file replaced ConfiggParser.readfp(), and ConfigParser.readfp() is no longer recognized.

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

1 participant