Strange Python internal error

J

JKPeck

We have a user on Windows with Python 2.6 who gets this error message when executing an import statement.
from extension import Template, Syntax, processcmd
SystemError: ..\Objects\listobject.c:169: bad argument to internal function

The module can be imported directly via
import extension
with no problem. And large numbers of other users execute this same code with no problem.

Does anybody have a clue as to how this might arise?

TIA,
Jon Peck
 
M

Miki Tebeka

Try to narrow it down:
from extension import Template
from extension import Syntax
from extension import processcmd

Which one fails? What is this "extension" package?
 
T

Terry Reedy

Testing the following code, I've differend return with python 3.1.2 and
3.2.2

running on two different machines with two different versions of Linux.

I get
# -*- coding: utf-8 -*-

import os
import sys
import platform

print('\nPython version: ', sys.version.split()[0])
print(platform.platform())

paths = ['/home/vincent/image.jpg', '/home/vincent/àéèîö.jpg']

for path in paths:
print('\nPath: {0}, Type: {1}'.format(path, type(path)))
if not os.path.exists(path) or not os.path.isfile(path):
print('File not found: {0}'.format(path))
else:
print('File exists')

I get

Python version: 3.2.2rc1
Windows-7-6.1.7601-SP1

Path: /home/vincent/image.jpg, Type: <class 'str'>
File not found: /home/vincent/image.jpg

Path: /home/vincent/àéèîö.jpg, Type: <class 'str'>
File not found: /home/vincent/àéèîö.jpg

so
[vincent@myhost ~]$ python string_2.py

Python version: 3.2.2
Linux-3.0-ARCH-x86_64-Pentium-R-_Dual-Core_CPU_T4500_@_2.30GHz-with-glibc2.2.5

Path: /home/vincent/image.jpg, Type: <class 'str'>
File exists
Traceback (most recent call last):
File "string_2.py", line 13, in <module>
print('\nPath: {0}, Type: {1}'.format(path, type(path)))
UnicodeEncodeError: 'ascii' codec can't encode characters in position
21-25: ordinal not in range(128)

is not specific to 3.2.2 in general. Try the two Python versions on the
same machine. Or try the test suite on each. See the test module doc for
how.
 
I

Ian Kelly

[vincent@myhost ~]$ python string_2.py

Python version:  3.2.2
Linux-3.0-ARCH-x86_64-Pentium-R-_Dual-Core_CPU_T4500_@_2.30GHz-with-glibc2.2.5

Path: /home/vincent/image.jpg, Type: <class 'str'>
File exists
Traceback (most recent call last):
  File "string_2.py", line 13, in <module>
    print('\nPath: {0}, Type: {1}'.format(path, type(path)))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 21-25:
ordinal not in range(128)

This looks like a terminal encoding issue on the second PC. Your
terminal is probably not using a unicode encoding, and so it is unable
to print a unicode string.

Cheers,
Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top