a while back i updated my python isntall to version 2.5.1. on a Windows
2000 server. It also runs Apache 2.2 & mod_python for Django.
Since the python upgrade, i got this "unknown encoding cp0" error.
I hadn't changed anything to the code. The errors always occured on
print commands. I found a workaround by adding str()
Thus
print "Blabla %s " % self.blabla
had to be changed to
print "Blabla %s " % str(self.blabla)
in order to solve the problem.
I found a page that clarifies it a bit but it doesn't seem to provide a
clear answer as to how to solve the problem.
https://lists.ubuntu.com/archives/bazaar/2006q4/019418.html
Any idea as to why i suddenly got that error and is there another
way to solve it (not using str)?
Regards,
Benedict
Nis
>>
> What is "self" referring to? Can you give us a stack trace? And which
> version of Django are you running (it is especially important to know if
> it is before or after the unicode branch got merged).
>
> Nis
self is referring to an object that i made to construct automatic
passwords to manage user creation.
class UserCreation(object):
...
As for the problem, it happens on both my Vista & Windows 2000
I use Python 2.5.1, Apache 2.2.4, mod_python 3.3.1,
Django svn version 6373
===================== Small trace ==============================
Traceback (most recent call last):
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
_real_get_response
81. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python25\lib\site-packages\django\contrib\auth\decorators.py"
in _checklogin
17. return view_func(request, *args, **kwargs)
File "E:\Sites\sitesdjango\user_creation\main\views.py" in user_creatie
50. u.create_all()
File "E:\Sites\sitesdjango\user_creation\packages\user\user_creation.py"
in create_all
48. self.report()
File "E:\Sites\sitesdjango\user_creation\packages\user\user_creation.py"
in report
329. print "Paswoord: %s " % self.paswoord
LookupError at /user_creatie/
unknown encoding: cp0
===================== Small trace ==============================
The full trace from Vista (same on Windows2000, identical setup):
==================================== Trace ============================
LookupError at /user_creatie/
unknown encoding: cp0
Request Method: POST
Request URL: http://user_creation/user_creatie/
Exception Type: LookupError
Exception Value: unknown encoding: cp0
Exception Location:
E:\Sites\sitesdjango\user_creation\packages\user\user_creation.py in
report, line 329
Python Executable: C:\Program Files\Apache Software
Foundation\Apache2.2\bin\httpd.exe
Python Version: 2.5.1
Traceback (innermost last)
Switch to copy-and-paste view
* C:\Python25\lib\site-packages\django\core\handlers\base.py in
_real_get_response
74. # Apply view middleware
75. for middleware_method in self._view_middleware:
76. response = middleware_method(request, callback,
callback_args, callback_kwargs)
77. if response:
78. return response
79.
80. try:
81. response = callback(request, *callback_args,
**callback_kwargs) ...
82. except Exception, e:
83. # If the view raised an exception, run it through exception
84. # middleware, and if the exception middleware returns a
85. # response, use that. Otherwise, reraise the exception.
86. for middleware_method in self._exception_middleware:
87. response = middleware_method(request, e)
▶ Local vars
Variable Value
callback
<function _checklogin at 0x0568FC70>
callback_args
()
callback_kwargs
{}
debug
<module 'django.views.debug' from
'C:\Python25\lib\site-packages\django\views\debug.py'>
e
LookupError('unknown encoding: cp0',)
exceptions
<module 'django.core.exceptions' from
'C:\Python25\lib\site-packages\django\core\exceptions.py'>
mail_admins
<function mail_admins at 0x054C65F0>
middleware_method
<bound method XViewMiddleware.process_view of
<django.middleware.doc.XViewMiddleware object at 0x05A4BCD0>>
request
<ModPythonRequest path:/user_creatie/, GET:<MultiValueDict: {}>,
POST:<MultiValueDict: {u'generate': [u'Generate'], u'initialen': [u''],
u'ccs_nr': [u''], u'login_internet': [u''], u'login_systeem': [u''],
u'edit_id': [u''], u'achternaam': [u'Vanderbruggen'], u'functie': [u''],
u'voornaam': [u'Kathi'], u'paswoord': [u''], u'telefoonnr': [u''],
u'email': [u'']}>, COOKIES:{'sessionid':
'16b11f2e2176ac612ac40ff5bc79c034'}, META:{'AUTH_TYPE': None,
'CONTENT_LENGTH': 0L, 'CONTENT_TYPE': None, 'GATEWAY_INTERFACE':
'CGI/1.1', 'HTTP_ACCEPT':
'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE':
'nl-be,nl;q=0.8,en;q=0.6,en-us;q=0.4,fr-be;q=0.2', 'HTTP_CONNECTION':
'keep-alive', 'HTTP_CONTENT_LENGTH': '154', 'HTTP_CONTENT_TYPE':
'application/x-www-form-urlencoded', 'HTTP_COOKIE':
'sessionid=16b11f2e2176ac612ac40ff5bc79c034', 'HTTP_HOST':
'user_creation', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER':
'http://user_creation/user_creatie/', 'HTTP_USER_AGENT': 'Mozilla/5.0
(Windows; U; Windows NT 6.0; nl; rv:1.8.1.6) Gecko/20070725
Firefox/2.0.0.6', 'PATH_INFO': '/', 'PATH_TRANSLATED': None,
'QUERY_STRING': None, 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_HOST': None,
'REMOTE_IDENT': None, 'REMOTE_USER': None, 'REQUEST_METHOD': 'POST',
'SCRIPT_NAME': None, 'SERVER_NAME': 'user_creation', 'SERVER_PORT': 0,
'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'mod_python'}>
resolver
<RegexURLResolver user_creation.urls ^/>
response
None
self
<django.core.handlers.modpython.ModPythonHandler object at
0x0541D370>
settings
<django.conf.LazySettings object at 0x054386B0>
urlconf
u'user_creation.urls'
urlresolvers
<module 'django.core.urlresolvers' from
'C:\Python25\lib\site-packages\django\core\urlresolvers.py'>
* C:\Python25\lib\site-packages\django\contrib\auth\decorators.py
in _checklogin
10. """
11. if not login_url:
12. from django.conf import settings
13. login_url = settings.LOGIN_URL
14. def _dec(view_func):
15. def _checklogin(request, *args, **kwargs):
16. if test_func(request.user):
17. return view_func(request, *args, **kwargs) ...
18. return HttpResponseRedirect('%s?%s=%s' % (login_url,
redirect_field_name, urlquote(request.get_full_path())))
19. _checklogin.__doc__ = view_func.__doc__
20. _checklogin.__dict__ = view_func.__dict__
21.
22. return _checklogin
23. return _dec
▶ Local vars
Variable Value
args
()
kwargs
{}
login_url
u'/login/'
redirect_field_name
u'next'
request
<ModPythonRequest path:/user_creatie/, GET:<MultiValueDict: {}>,
POST:<MultiValueDict: {u'generate': [u'Generate'], u'initialen': [u''],
u'ccs_nr': [u''], u'login_internet': [u''], u'login_systeem': [u''],
u'edit_id': [u''], u'achternaam': [u'Vanderbruggen'], u'functie': [u''],
u'voornaam': [u'Kathi'], u'paswoord': [u''], u'telefoonnr': [u''],
u'email': [u'']}>, COOKIES:{'sessionid':
'16b11f2e2176ac612ac40ff5bc79c034'}, META:{'AUTH_TYPE': None,
'CONTENT_LENGTH': 0L, 'CONTENT_TYPE': None, 'GATEWAY_INTERFACE':
'CGI/1.1', 'HTTP_ACCEPT':
'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE':
'nl-be,nl;q=0.8,en;q=0.6,en-us;q=0.4,fr-be;q=0.2', 'HTTP_CONNECTION':
'keep-alive', 'HTTP_CONTENT_LENGTH': '154', 'HTTP_CONTENT_TYPE':
'application/x-www-form-urlencoded', 'HTTP_COOKIE':
'sessionid=16b11f2e2176ac612ac40ff5bc79c034', 'HTTP_HOST':
'user_creation', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER':
'http://user_creation/user_creatie/', 'HTTP_USER_AGENT': 'Mozilla/5.0
(Windows; U; Windows NT 6.0; nl; rv:1.8.1.6) Gecko/20070725
Firefox/2.0.0.6', 'PATH_INFO': '/', 'PATH_TRANSLATED': None,
'QUERY_STRING': None, 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_HOST': None,
'REMOTE_IDENT': None, 'REMOTE_USER': None, 'REQUEST_METHOD': 'POST',
'SCRIPT_NAME': None, 'SERVER_NAME': 'user_creation', 'SERVER_PORT': 0,
'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'mod_python'}>
test_func
<function <lambda> at 0x0568F6F0>
view_func
<function user_creatie at 0x0568FC30>
* E:\Sites\sitesdjango\user_creation\main\views.py in user_creatie
43. if request.method == 'POST':
44. if request.POST.has_key('generate'):
45. voornaam = request.POST['voornaam']
46. achternaam = request.POST['achternaam']
47. u = UserCreation()
48. u.voornaam = voornaam
49. u.achternaam = achternaam
50. u.create_all() ...
51. f = GebruikerForm({ "voornaam": voornaam,
52. "achternaam": achternaam,
53. "initialen": u.initialen,
54. "email": u.email,
55. "paswoord": u.paswoord,
56. "login_systeem": u.login_systeem,
▶ Local vars
Variable Value
GebruikerForm
<class 'django.newforms.models.GebruikerForm'>
achternaam
u'Vanderbruggen'
edit_id
u''
f
<django.newforms.models.GebruikerForm object at 0x05B72890>
message
u''
request
<ModPythonRequest path:/user_creatie/, GET:<MultiValueDict: {}>,
POST:<MultiValueDict: {u'generate': [u'Generate'], u'initialen': [u''],
u'ccs_nr': [u''], u'login_internet': [u''], u'login_systeem': [u''],
u'edit_id': [u''], u'achternaam': [u'Vanderbruggen'], u'functie': [u''],
u'voornaam': [u'Kathi'], u'paswoord': [u''], u'telefoonnr': [u''],
u'email': [u'']}>, COOKIES:{'sessionid':
'16b11f2e2176ac612ac40ff5bc79c034'}, META:{'AUTH_TYPE': None,
'CONTENT_LENGTH': 0L, 'CONTENT_TYPE': None, 'GATEWAY_INTERFACE':
'CGI/1.1', 'HTTP_ACCEPT':
'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE':
'nl-be,nl;q=0.8,en;q=0.6,en-us;q=0.4,fr-be;q=0.2', 'HTTP_CONNECTION':
'keep-alive', 'HTTP_CONTENT_LENGTH': '154', 'HTTP_CONTENT_TYPE':
'application/x-www-form-urlencoded', 'HTTP_COOKIE':
'sessionid=16b11f2e2176ac612ac40ff5bc79c034', 'HTTP_HOST':
'user_creation', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER':
'http://user_creation/user_creatie/', 'HTTP_USER_AGENT': 'Mozilla/5.0
(Windows; U; Windows NT 6.0; nl; rv:1.8.1.6) Gecko/20070725
Firefox/2.0.0.6', 'PATH_INFO': '/', 'PATH_TRANSLATED': None,
'QUERY_STRING': None, 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_HOST': None,
'REMOTE_IDENT': None, 'REMOTE_USER': None, 'REQUEST_METHOD': 'POST',
'SCRIPT_NAME': None, 'SERVER_NAME': 'user_creation', 'SERVER_PORT': 0,
'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'mod_python'}>
submit_action
u'Add'
u
<user_creation.packages.user.user_creation.UserCreation object at
0x05B72B70>
voornaam
u'Kathi'
* E:\Sites\sitesdjango\user_creation\packages\user\user_creation.py
in create_all
41.
42. if ( self.voornaam != None and self.achternaam != None ):
43. self.clean_names()
44. self.create_initials()
45. self.create_email()
46. self.create_logins()
47. self.create_password()
48. self.report() ...
49. else:
50. print "Geen geldige voor -en/of achternaam"
51.
52. def read_data(self):
53. """
54. Read voornaam & achternaam from the prompt
▶ Local vars
Variable Value
ask_input
False
self
<user_creation.packages.user.user_creation.UserCreation object at
0x05B72B70>
* E:\Sites\sitesdjango\user_creation\packages\user\user_creation.py
in report
322. def report(self):
323. """
324. """
325. print " "
326. print " "
327. print "Emailen naar Hein & de Office manager"
328. print
"-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<"
329. print "Paswoord: %s " % self.paswoord ...
330. print
"-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<"
331. print " "
332. print " "
333. print "Emailen naar Hein, Martin, Barbara"
334. print
"-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<"
335. print "Initialen: %s " % str(self.initialen)
▶ Local vars
Variable Value
self
<user_creation.packages.user.user_creation.UserCreation object at
0x05B72B70>
Traceback (most recent call last):
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
_real_get_response
81. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python25\lib\site-packages\django\contrib\auth\decorators.py"
in _checklogin
17. return view_func(request, *args, **kwargs)
File "E:\Sites\sitesdjango\user_creation\main\views.py" in user_creatie
50. u.create_all()
File "E:\Sites\sitesdjango\user_creation\packages\user\user_creation.py"
in create_all
48. self.report()
File "E:\Sites\sitesdjango\user_creation\packages\user\user_creation.py"
in report
329. print "Paswoord: %s " % self.paswoord
LookupError at /user_creatie/
unknown encoding: cp0
Request information
GET
No GET data
POST
Variable Value
generate
u'Generate'
initialen
u''
ccs_nr
u''
login_internet
u''
login_systeem
u''
edit_id
u''
achternaam
u'Vanderbruggen'
functie
u''
voornaam
u'Kathi'
paswoord
u''
telefoonnr
u''
email
u''
COOKIES
Variable Value
sessionid
u'16b11f2e2176ac612ac40ff5bc79c034'
META
Variable Value
AUTH_TYPE
None
CONTENT_LENGTH
0L
CONTENT_TYPE
None
GATEWAY_INTERFACE
u'CGI/1.1'
HTTP_ACCEPT
u'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'
HTTP_ACCEPT_CHARSET
u'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
HTTP_ACCEPT_ENCODING
u'gzip,deflate'
HTTP_ACCEPT_LANGUAGE
u'nl-be,nl;q=0.8,en;q=0.6,en-us;q=0.4,fr-be;q=0.2'
HTTP_CONNECTION
u'keep-alive'
HTTP_CONTENT_LENGTH
u'154'
HTTP_CONTENT_TYPE
u'application/x-www-form-urlencoded'
HTTP_COOKIE
u'sessionid=16b11f2e2176ac612ac40ff5bc79c034'
HTTP_HOST
u'user_creation'
HTTP_KEEP_ALIVE
u'300'
HTTP_REFERER
u'http://user_creation/user_creatie/'
HTTP_USER_AGENT
u'Mozilla/5.0 (Windows; U; Windows NT 6.0; nl; rv:1.8.1.6)
Gecko/20070725 Firefox/2.0.0.6'
PATH_INFO
u'/'
PATH_TRANSLATED
None
QUERY_STRING
None
REMOTE_ADDR
u'127.0.0.1'
REMOTE_HOST
None
REMOTE_IDENT
None
REMOTE_USER
None
REQUEST_METHOD
u'POST'
SCRIPT_NAME
None
SERVER_NAME
u'user_creation'
SERVER_PORT
0
SERVER_PROTOCOL
u'HTTP/1.1'
SERVER_SOFTWARE
u'mod_python'
Settings
Using settings module user_creation.settings
Setting Value
ABSOLUTE_URL_OVERRIDES
{}
ADMINS
(('Benedict Verheyen', 'benedict...@vdl.be'),)
ADMIN_FOR
()
ADMIN_MEDIA_PREFIX
u'/media/'
ALLOWED_INCLUDE_ROOTS
()
APPEND_SLASH
True
AUTHENTICATION_BACKENDS
('django.contrib.auth.backends.ModelBackend',)
BANNED_IPS
()
CACHE_BACKEND
u'simple://'
CACHE_MIDDLEWARE_KEY_PREFIX
u''
CACHE_MIDDLEWARE_SECONDS
600
COMMENTS_ALLOW_PROFANITIES
False
COMMENTS_BANNED_USERS_GROUP
None
COMMENTS_FIRST_FEW
0
COMMENTS_MODERATORS_GROUP
None
COMMENTS_SKETCHY_USERS_GROUP
None
DATABASE_ENGINE
u'postgresql_psycopg2'
DATABASE_HOST
u''
DATABASE_NAME
u'user_creation'
DATABASE_OPTIONS
{}
DATABASE_PASSWORD
u'********************'
DATABASE_PORT
u''
DATABASE_USER
u'postgres'
DATETIME_FORMAT
u'N j, Y, P'
DATE_FORMAT
u'd/m/Y'
DEBUG
True
DEFAULT_CHARSET
u'utf-8'
DEFAULT_CONTENT_TYPE
u'text/html'
DEFAULT_FROM_EMAIL
u'webmaster@localhost'
DISALLOWED_USER_AGENTS
()
EMAIL_HOST
u'localhost'
EMAIL_HOST_PASSWORD
u'********************'
EMAIL_HOST_USER
u''
EMAIL_PORT
25
EMAIL_SUBJECT_PREFIX
u'[Django] '
EMAIL_USE_TLS
False
FILE_CHARSET
u'utf-8'
FIXTURE_DIRS
()
IGNORABLE_404_ENDS
('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'favicon.ico',
'.php')
IGNORABLE_404_STARTS
('/cgi-bin/', '/_vti_bin', '/_vti_inf')
INSTALLED_APPS
['django.contrib.auth', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sites',
'django.contrib.admin', 'user_creation.main']
INTERNAL_IPS
()
JING_PATH
u'/usr/bin/jing'
LANGUAGES
(('ar', 'Arabic'), ('bn', 'Bengali'), ('bg', 'Bulgarian'), ('ca',
'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de',
'German'), ('el', 'Greek'), ('en', 'English'), ('es', 'Spanish'),
('es_AR', 'Argentinean Spanish'), ('fa', 'Persian'), ('fi', 'Finnish'),
('fr', 'French'), ('ga', 'Gaeilge'), ('gl', 'Galician'), ('hu',
'Hungarian'), ('he', 'Hebrew'), ('hr', 'Croatian'), ('is', 'Icelandic'),
('it', 'Italian'), ('ja', 'Japanese'), ('ko', 'Korean'), ('km',
'Khmer'), ('kn', 'Kannada'), ('lv', 'Latvian'), ('mk', 'Macedonian'),
('nl', 'Dutch'), ('no', 'Norwegian'), ('pl', 'Polish'), ('pt',
'Portugese'), ('pt-br', 'Brazilian'), ('ro', 'Romanian'), ('ru',
'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sr', 'Serbian'),
('sv', 'Swedish'), ('ta', 'Tamil'), ('te', 'Telugu'), ('tr', 'Turkish'),
('uk', 'Ukrainian'), ('zh-cn', 'Simplified Chinese'), ('zh-tw',
'Traditional Chinese'))
LANGUAGES_BIDI
('he', 'ar', 'fa')
LANGUAGE_CODE
u'en-us'
LOGIN_REDIRECT_URL
u'/accounts/profile/'
LOGIN_URL
u'/accounts/login/'
LOGOUT_URL
u'/accounts/logout/'
MANAGERS
(('Benedict Verheyen', 'benedict...@vdl.be'),)
MEDIA_ROOT
u'E:/Sites/sitesdjango/user_creation/media'
MEDIA_URL
u'/media'
MIDDLEWARE_CLASSES
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware')
MONTH_DAY_FORMAT
u'F j'
PREPEND_WWW
False
PROFANITIES_LIST
u'********************'
ROOT_URLCONF
u'user_creation.urls'
SECRET_KEY
u'********************'
SEND_BROKEN_LINK_EMAILS
False
SERVER_EMAIL
u'root@localhost'
SESSION_COOKIE_AGE
1209600
SESSION_COOKIE_DOMAIN
None
SESSION_COOKIE_NAME
u'sessionid'
SESSION_COOKIE_SECURE
False
SESSION_ENGINE
u'django.contrib.sessions.backends.db'
SESSION_EXPIRE_AT_BROWSER_CLOSE
False
SESSION_FILE_PATH
u'/tmp/'
SESSION_SAVE_EVERY_REQUEST
False
SETTINGS_MODULE
u'user_creation.settings'
SITE_ID
1
TEMPLATE_CONTEXT_PROCESSORS
('django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media')
TEMPLATE_DEBUG
True
TEMPLATE_DIRS
('E:/Sites/sitesdjango/templates',
'E:/Sites/sitesdjango/templates/user_creation')
TEMPLATE_LOADERS
('django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source')
TEMPLATE_STRING_IF_INVALID
u''
TEST_DATABASE_CHARSET
None
TEST_DATABASE_COLLATION
None
TEST_DATABASE_NAME
None
TEST_RUNNER
u'django.test.simple.run_tests'
TIME_FORMAT
u'P'
TIME_ZONE
u'Europe/Brussels'
TRANSACTIONS_MANAGED
False
URL_VALIDATOR_USER_AGENT
u'Django/0.97-pre-SVN-6373 (http://www.djangoproject.com)'
USE_ETAGS
False
USE_I18N
True
YEAR_MONTH_FORMAT
u'F Y'
==================================== Trace ============================
I could test it by reverting my local svn version to an older version,
before the unicode branch got merged.
What revision would that be?
Hhhmn, i check the commit logs and revision 5600 should be the version
just before the unicode branch got merged.
I checked out version 5600 (i did a svn co -r5600 in another directory.
Is there a better way to do this? revert?) and tried it and i don't get
the encoding error !
So it looks like it probably has to do with the unicode merge.
Maybe this part of the link that i posted in my first post could help:
- if _cached_user_encoding is None:
+ # Windows returns 'cp0' to indicate there is no code page. So we'll
just
+ # treat that as ASCII, and not support printing unicode characters
to the
+ # console.
+ if _cached_user_encoding in (None, 'cp0'):
_cached_user_encoding = 'ascii'
return _cached_user_encoding
Regards,
Benedict