[issue3145] help> modules os raises UnicodeDecodeError

2008-06-19 Thread Michael Yang

New submission from Michael Yang <[EMAIL PROTECTED]>:

>>> help()
help> modules os
Here is a list of matching modules.  Enter any module name to get more help.

posix - This module provides access to operating system
...
stringprep - Library that exposes various tables found in the StringPrep
RFC 3454.
Traceback (most recent call last):
  File "", line 1, in 
...
File "/home/michael/python3/3.0b1/lib/python3.0/codecs.py", line 300, in
decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 8-11:
invalid data

--
components: Interpreter Core
messages: 68419
nosy: msyang
severity: normal
status: open
title: help> modules os raises UnicodeDecodeError
type: behavior
versions: Python 3.0

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3145>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3635] pickle.dumps cannot save instance of dict-derived class that overrides __getattribute__

2008-08-21 Thread Michael Yang

New submission from Michael Yang <[EMAIL PROTECTED]>:

# pickle.dumps is not able to process an instance of
# a class that inherits from 'dict' and
# overrides the built-in __getattribute__ method
# but can successfully process one that 
# overrides the__getattr__ method

>>> class Examp1(dict):
...   def __getattr__(self,name):
... return self[name]
... 
>>> class Examp2(dict):
...   def __getattribute__(self,name):
... return self[name]
... 
>>> ex1 = Examp1()
>>> ex2 = Examp2()
>>> ex1['aKey'] = (3,4)
>>> ex2['aKey2'] = (4,5)
>>> ex1
{'aKey': (3, 4)}
>>> ex1.aKey
(3, 4)
>>> ex2
{'aKey2': (4, 5)}
>>> ex2.aKey2
(4, 5)
>>> import pickle
>>> pickle.dumps(ex1)
b'\x80\x03c__main__\nexamp1\nq\x00)\x81q\x01X\x04\x00\x00\x00aKeyq\x02K\x03K\x04\x86q\x03s}q\x04b.'
>>> pickle.dumps(ex2)
Traceback (most recent call last):
  File "", line 1, in 
  File "[hidden]/python3/3.0b2/common/lib/python3.0/pickle.py", line
1319, in dumps
Pickler(f, protocol).dump(obj)
  File "", line 3, in __getattribute__
KeyError: '__reduce_ex__'

--
components: Extension Modules
messages: 71671
nosy: msyang
severity: normal
status: open
title: pickle.dumps cannot save instance of dict-derived class that overrides 
__getattribute__
type: behavior
versions: Python 2.5, Python 3.0

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3635>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4584] doctest fails to display bytes type

2008-12-07 Thread Michael Yang

New submission from Michael Yang <[EMAIL PROTECTED]>:

doctest.testmod() fails when attempting to echo back a bytes type with
ord() > 128.


def ok():
   """
>>> bytes([255,])
b'\xff'

"""
pass

def notOK():
"""
>>> b'\xff'

"""
pass

import doctest
doctest.testmod()

Traceback (most recent call last):
...
UnicodeEncodeError: 'ascii' codec can't encode character '\xff' in
position 141: ordinal not in range(128)

--
components: Extension Modules
messages: 77264
nosy: msyang
severity: normal
status: open
title: doctest fails to display bytes type
type: behavior
versions: Python 3.0

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4584>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4886] test/regrtest.py contains error on __import__

2009-01-08 Thread Michael Yang

New submission from Michael Yang :

I want to use the included test.regrtest (located in 
$pythondir/lib/python[ver]/test) to regression test some of my own 
scripts located in directory myDir.  The script has some nice 
configurability features to skip some tests based on machine 
configurations, etc. that a vanilla unittest suite doesn't include 
automatically.  However, it seems that the script regrtest.py has an 
error following the __import__ line.

Here's my setup:

/sample.py
/myDir
/__init__.py
/test_file1.py
/test_file2.py
/...

in sample.py:

{{{
#!python
#!/usr/bin/env python
import test.regrtest as rt
rt.main(tests = ['myDir.test_file1','myDir.test_file2'], \
quiet = False, verbose = True)
}}}

running sample.py yields:

{{{
#!sh
myDir.test_file1
myDir.test_file1 skipped -- No module named myDir.test_file1
myDir.test_file2
myDir.test_file2 skipped -- No module named myDir.test_file2
2 tests skipped:
myDir.test_file1 myDir.test_file2
2 skips unexpected on win32:
myDir.test_file1 myDir.test_file2
}}}

This is due to the code snippet in regrtest.py around line 554:

{{{
#!python
...
if test.startswith('test.'):
abstest = test
else:
# Always import it from the test package
abstest = 'test.' + test
the_package = __import__(abstest, globals(), locals(), [])
the_module = getattr(the_package, test)
...
}}}

should be changed to:
{{{
#!python
...
if test.startswith('test.'):
abstest = test
modName = test[len('test.'):]
else:
# Always import it from the test package
abstest = 'test.' + test
modName = test
the_package = __import__(abstest, globals(), locals(), [])
the_module = getattr(the_package, modName)
...
}}}

This way, the the_module will correctly find the module name in 
'the_package'.

A further recommendation: the main() module should be able to work with 
test directories with name other than 'test.*'.  Otherwise, users 
wishing to use the main() on other directories will have to name them 
'test.'  Depending on the user's directory's position in sys.path 
(before or after $pythondir/lib/python[ver]), regrtest.main() will 
either fail due to the 'from test import ...' statements being shadowed 
by the user's 'test' directory or the user's 'test' directory being 
shadowed by the standard library's.

--
components: Library (Lib)
messages: 79442
nosy: msyang
severity: normal
status: open
title: test/regrtest.py contains error on __import__
versions: Python 2.6, Python 3.0

___
Python tracker 
<http://bugs.python.org/issue4886>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4886] test/regrtest.py contains error on __import__

2009-01-08 Thread Michael Yang

Changes by Michael Yang :


--
type:  -> behavior

___
Python tracker 
<http://bugs.python.org/issue4886>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com