#63 Ascii codec can't encode character
Closed: Fixed 7 years ago Opened 7 years ago by robyduck.

I'm wondering if there is a workaround to this:

Traceback (most recent call last):
File "/usr/bin/pgimport", line 9, in <module>
load_entry_point('pagure-importer==1.2.2', 'console_scripts', 'pgimport')()
File "/usr/lib/python2.7/site-packages/click/core.py", line 716, in call
return self.main(args, kwargs)
File "/usr/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback,
ctx.params)
File "/usr/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(
args, **kwargs)
File "/usr/lib/python2.7/site-packages/pagure_importer/commands/fedorahosted.py", line 31, in fedorahosted
trac_importer.import_issues(repo_name=repo_name, repo_folder=REPO_PATH)
File "/usr/lib/python2.7/site-packages/pagure_importer/utils/importer_trac.py", line 76, in import_issues
pagure_issue.attachment[attach_name], attach_name)
File "/usr/lib/python2.7/site-packages/pagure_importer/utils/git.py", line 21, in get_secure_filename
werkzeug.secure_filename(str(filename)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 16: ordinal not in range(128)


Happens when importing tickets to the tmp/repo from fedorahosted.org

Hi @robyduck can you tell me which fedorahosted projects you were trying to import ?

The problem happens when we do:

werkzeug.secure_filename(str(filename)))

And filename is unicode.

I am having the same issue migrating fedora-latam trac.

removing the casting to str may solve the problem, but I am not sure about having a patch with that since I am not sure about the security implications.

Maybe we could have
werkzeug.secure_filename(unicode(filename)))
but then we would make sure the filename comes as unicode

this should be fixed by PR#80 . And will be release in the next version. (likely to be next week)

@cverna changed the status to Closed

7 years ago

Sorry, but this is still not working:

Traceback (most recent call last):
File "/usr/bin/pgimport", line 9, in <module>
load_entry_point('pagure-importer==1.2.2', 'console_scripts', 'pgimport')()
File "/usr/lib/python2.7/site-packages/click/core.py", line 716, in call
return self.main(args, kwargs)
File "/usr/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback,
ctx.params)
File "/usr/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(
args, **kwargs)
File "/usr/lib/python2.7/site-packages/pagure_importer/commands/fedorahosted.py", line 31, in fedorahosted
trac_importer.import_issues(repo_name=repo_name, repo_folder=REPO_PATH)
File "/usr/lib/python2.7/site-packages/pagure_importer/utils/importer_trac.py", line 76, in import_issues
pagure_issue.attachment[attach_name], attach_name)
File "/usr/lib/python2.7/site-packages/pagure_importer/utils/git.py", line 21, in get_secure_filename
werkzeug.secure_filename(str(filename)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 16: ordinal not in range(128)

Tested right now.

@robyduck I just had a try at importing fedora-websites on stg pagure with the latest importer. You can have a look here

It is almost complete my internet connection died :boom: while importing issue 383 out of 414

I will package this version of the importer later this week

Any news of the updated release?

I am in the middle of moving house and country. But I ll try to do the release the next couple days.

@robyduck I have just released version 2.0.1. Check the infra mailing list for details :smile:

Yeah, I tested it just after reading the mail on the Infra ML. Thank you, working fine now!

Login to comment on this ticket.

Metadata