Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CKAN 2.9.4 cannot load JS translations when using Python 2.7 #6531

@frafra

Description

@frafra

This code is not Python 2.7 compatible:

translations = json.load(open(source, u'r', encoding=u'utf-8'))

In Python 2, encoding is not a valid argument for the open function, but it is for the json.load.

Here is the commit which introduced the regression: a280cf1

2021-11-11 15:42:28,678 ERROR [ckan.config.middleware.flask_app] 'encoding' is an invalid keyword argument for this function
Traceback (most recent call last):
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1935, in dispatch_request
   return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/lib/ckan/venv/src/ckan/ckan/views/api.py", line 482, in i18n_js_translations
    translations = json.load(open(source, u'r', encoding=u'utf-8'))
TypeError: 'encoding' is an invalid keyword argument for this function

It seems to have been fixed partially already in another file: b2b92a4

Related issue: #6051

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions