[issue13429] provide __file__ to extension init function

2011-12-25 Thread Stefan Behnel

Stefan Behnel  added the comment:

Any comments on the last patch?

--

___
Python tracker 

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



[issue13639] UnicodeDecodeError when creating tar.gz with unicode name

2011-12-25 Thread Lars Gustäbel

Lars Gustäbel  added the comment:

I think we should wrap this up as soon as possible, because it has already 
absorbed too much of our time. The issue we discuss here is a tiny glitch 
triggered by a corner-case. My original idea was to fix it in a minimal sort of 
way that is backwards-compatible.

There are at least 4 different solutions now:

1. Keep the patch.
2. Revert the patch, leave everything as it was as wontfix.
3. Don't write an FNAME field at all if the filename that is passed is a 
unicode string.
4. Rewrite the FNAME code the way Terry suggests. This seems to me like the 
most complex solution, because we have to fix gzip.py as well, because the code 
in question was originally taken from the gzip module. (BTW, both the tarfile 
and gzip module discard the FNAME field when a file is opened for reading.)

My favorites are 1 and 3 ;-)

--
assignee:  -> lars.gustaebel
priority: normal -> low

___
Python tracker 

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



[issue13639] UnicodeDecodeError when creating tar.gz with unicode name

2011-12-25 Thread Jason R. Coombs

Jason R. Coombs  added the comment:

I also feel (1) or (3) is best for this issue. If there is a _better_ 
implementation, it should be reserved for a separate improvement to Python 
3.2+.

I lean slightly toward (3) because it would support filenames with Unicode 
characters other than latin-1 (as long as the file system allows it to be 
saved), because I suspect it would enable tests such as this to pass: 
https://bitbucket.org/jaraco/cpython-issue11638/changeset/9e9ea96eb0dd#chg-Lib/distutils/tests/test_archive_util.py

--
Added file: http://bugs.python.org/file24090/smime.p7s

___
Python tracker 

___

smime.p7s
Description: S/MIME cryptographic signature
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6028] Interpreter aborts when chaining an infinite number of exceptions

2011-12-25 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

FWIW, I concur with Antoine on this one.

--
nosy: +rhettinger

___
Python tracker 

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



[issue13033] Add shutil.chowntree

2011-12-25 Thread Tigger Level-5

Tigger Level-5  added the comment:

Hi Éric,

Apologies for the late response, attached is the patch. Let me know if
I need any changes or anything else.

Best,
Tigger

On Sat, Nov 5, 2011 at 11:01 AM, Éric Araujo  wrote:
>
> Éric Araujo  added the comment:
>
> Tigger: Could you provide a patch for Python 3.3? (more info at 
> http://docs.python.org/devguide/)
>
> --
>
> ___
> Python tracker 
> 
> ___

--
keywords: +patch
Added file: http://bugs.python.org/file24091/chowntree.patch

___
Python tracker 

___diff -r 2b47f0146639 Doc/library/shutil.rst
--- a/Doc/library/shutil.rstSun Sep 25 17:36:31 2011 +0200
+++ b/Doc/library/shutil.rstMon Sep 26 17:18:43 2011 -0500
@@ -196,6 +196,33 @@
 
.. versionadded:: 3.3
 
+.. function:: chowntree(path, user=None, group=None, followlinks=False)
+
+   Change owner *user* and/or *group* of the given *path* and all contents 
recursively.
+
+   *user* can be a system user name or a uid; the same applies to *group*. At
+   least one argument is required.
+
+   See also :func:`os.chown` and :func:`os.walk`, the underlying functions.
+
+   By default, :func:`walk` will not walk down into symbolic links that 
resolve to
+   directories. Set *followlinks* to ``True`` to visit directories pointed to 
by
+   symlinks, on systems that support them.
+
+   .. note::
+
+  Be aware that setting *followlinks* to ``True`` can lead to infinite 
recursion if a
+  link points to a parent directory of itself. This is due to the fact 
that the underlying
+  function :func:`os.walk` does not keep track of
+  the directories it visited already.
+
+   .. note::
+
+  If there is an error with the underlying :func:`os.walk` method, then 
any files whose
+  ownership was successfully changed will be reverted back to the original 
ownership.
+
+   Availability: Unix.
+
 
 .. exception:: Error
 
diff -r 2b47f0146639 Lib/shutil.py
--- a/Lib/shutil.py Sun Sep 25 17:36:31 2011 +0200
+++ b/Lib/shutil.py Mon Sep 26 17:18:43 2011 -0500
@@ -822,3 +822,57 @@
 raise LookupError("no such group: {!r}".format(group))
 
 os.chown(path, _user, _group)
+
+
+def chowntree(path, user=None, group=None, followlinks=False):
+"""Change owner user and group of the given path and all contents 
recursively.
+
+user and group can be the uid/gid or the user/group names, and in that 
case,
+they are converted to their respective uid/gid. followlinks tells us 
whether we should
+follow symlinks. This may lead to infinite recursion if links loop back.
+
+The dictionary _modified_items, will keep track of the old ownership 
details,
+with keys being the full path, and values being tuples where the first 
element is
+the uid and the second element is the gid. This way if there are any 
errors that
+arise, we can undo any ownership changes to the old state.
+
+"""
+
+if user is None and group is None:
+raise ValueError("user and/or group must be set")
+
+_user = user
+_group = group
+
+# -1 means don't change it
+if user is None:
+_user = -1
+# user can either be an int (the uid) or a string (the system username)
+elif isinstance(user, str):
+_user = _get_uid(user)
+if _user is None:
+raise LookupError("no such user: {!r}".format(user))
+
+if group is None:
+_group = -1
+elif not isinstance(group, int):
+_group = _get_gid(group)
+if _group is None:
+raise LookupError("no such group: {!r}".format(group))
+
+
+_modified_items = dict()
+def _listdir_errorhandler(oserror):
+for path, stat in _modified_items.items():
+os.chown(path, stat.st_uid, stat.st_gid)
+raise oserror
+
+if(os.path.isdir(path)):
+for root, dirs, files in os.walk(path, onerror = 
_listdir_errorhandler, followlinks = followlinks):
+for item in (files + dirs):
+_full_file_path = os.path.join(root, item)
+
+stat_info = os.stat(_full_file_path)
+os.chown(_full_file_path, _user, _group)
+_modified_items[_full_file_path] = (stat_info.st_uid, 
stat_info.st_gid)
+
+os.chown(path, _user, _group)
diff -r 2b47f0146639 Lib/test/test_shutil.py
--- a/Lib/test/test_shutil.py   Sun Sep 25 17:36:31 2011 +0200
+++ b/Lib/test/test_shutil.py   Mon Sep 26 17:18:43 2011 -0500
@@ -770,6 +770,50 @@
 check_chown(filename, uid, gid)
 shutil.chown(dirname, user, group)
 check_chown(dirname, uid, gid)
+
+
+@unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
+@unittest.skipUnless(hasattr(os, 'chown'), 'requires os.chown')
+def test_chowntree(self):
+
+# cleaned-up

[issue11638] python setup.py sdist --formats tar* crashes if version is unicode

2011-12-25 Thread Jason R. Coombs

Changes by Jason R. Coombs :


--
keywords: +patch
Added file: http://bugs.python.org/file24092/774933cf7775.diff

___
Python tracker 

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



[issue13662] os.listdir bug

2011-12-25 Thread wang

New submission from wang :

when I use os.list the return value is like this:
['some.xml', '\ufeff9158.xml']
but the file name have not the '\ufeff'.
because this problem the script can't runing.

--
messages: 150252
nosy: guxianminer
priority: normal
severity: normal
status: open
title: os.listdir bug
versions: Python 3.1

___
Python tracker 

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



[issue11638] python setup.py sdist --formats tar* crashes if version is unicode

2011-12-25 Thread Jason R. Coombs

Jason R. Coombs  added the comment:

Thanks to Lars for suggesting the fix, replacing 'w|gz' with 'w:gz'. I 
attempted this change in the latest revision of my fork (774933cf7775.diff). 
While this change does address the issue if a unicode string is passed which 
can be encoded using the default encoding. However, if a latin-1 string is 
passed or another multi-byte unicode character is passed, a UnicodeDecodeError 
still occurs (though now in gzip.py). Here's the test results and tracebacks:

PS C:\Users\jaraco\projects\public\cpython> python 
.\lib\distutils\tests\test_archive_util.py
test_check_archive_formats (__main__.ArchiveUtilTestCase) ... ok
test_compress_deprecated (__main__.ArchiveUtilTestCase) ... skipped 'The 
compress program is required'
test_make_archive (__main__.ArchiveUtilTestCase) ... ok
test_make_archive_cwd (__main__.ArchiveUtilTestCase) ... ok
test_make_archive_owner_group (__main__.ArchiveUtilTestCase) ... ok
test_make_tarball (__main__.ArchiveUtilTestCase) ... ok
test_make_tarball_unicode (__main__.ArchiveUtilTestCase) ... ok
test_make_tarball_unicode_extended (__main__.ArchiveUtilTestCase) ... ERROR
test_make_tarball_unicode_latin1 (__main__.ArchiveUtilTestCase) ... ERROR
test_make_zipfile (__main__.ArchiveUtilTestCase) ... ok
test_tarfile_root_owner (__main__.ArchiveUtilTestCase) ... skipped 'Requires 
grp and pwd support'
test_tarfile_vs_tar (__main__.ArchiveUtilTestCase) ... skipped 'Need the tar 
command to run'

==
ERROR: test_make_tarball_unicode_extended (__main__.ArchiveUtilTestCase)
--
Traceback (most recent call last):
  File ".\lib\distutils\tests\test_archive_util.py", line 305, in 
test_make_tarball_unicode_extended
self._make_tarball(u'のアーカイブ') # japanese for archive
  File ".\lib\distutils\tests\test_archive_util.py", line 64, in _make_tarball
make_tarball(splitdrive(base_name)[1], '.')
  File "C:\Users\jaraco\projects\public\cpython\Lib\distutils\archive_util.py",
line 101, in make_tarball
tar = tarfile.open(archive_name, 'w:%s' % tar_compression[compress])
  File "C:\Users\jaraco\projects\public\cpython\Lib\tarfile.py", line 1676, in 
open
return func(name, filemode, fileobj, **kwargs)
  File "C:\Users\jaraco\projects\public\cpython\Lib\tarfile.py", line 1724, in 
gzopen
gzip.GzipFile(name, mode, compresslevel, fileobj),
  File "C:\Users\jaraco\projects\public\cpython\Lib\gzip.py", line 127, in 
__init__
self._write_gzip_header()
  File "C:\Users\jaraco\projects\public\cpython\Lib\gzip.py", line 172, in 
_write_gzip_header
self.fileobj.write(fname + '\000')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: 
ordinal not in range(128)

==
ERROR: test_make_tarball_unicode_latin1 (__main__.ArchiveUtilTestCase)
--
Traceback (most recent call last):
  File ".\lib\distutils\tests\test_archive_util.py", line 297, in 
test_make_tarball_unicode_latin1
self._make_tarball(u'årchiv') # note this isn't a real word
  File ".\lib\distutils\tests\test_archive_util.py", line 64, in _make_tarball
make_tarball(splitdrive(base_name)[1], '.')
  File "C:\Users\jaraco\projects\public\cpython\Lib\distutils\archive_util.py",
line 101, in make_tarball
tar = tarfile.open(archive_name, 'w:%s' % tar_compression[compress])
  File "C:\Users\jaraco\projects\public\cpython\Lib\tarfile.py", line 1676, in 
open
return func(name, filemode, fileobj, **kwargs)
  File "C:\Users\jaraco\projects\public\cpython\Lib\tarfile.py", line 1724, in 
gzopen
gzip.GzipFile(name, mode, compresslevel, fileobj),
  File "C:\Users\jaraco\projects\public\cpython\Lib\gzip.py", line 127, in 
__init__
self._write_gzip_header()
  File "C:\Users\jaraco\projects\public\cpython\Lib\gzip.py", line 172, in 
_write_gzip_header
self.fileobj.write(fname + '\000')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 0:
ordinal not in range(128)

--
Ran 12 tests in 0.058s

FAILED (errors=2, skipped=3)
Traceback (most recent call last):
  File ".\lib\distutils\tests\test_archive_util.py", line 311, in 
run_unittest(test_suite())
  File "C:\Users\jaraco\projects\public\cpython\Lib\test\test_support.py", line
1094, in run_unittest
_run_suite(suite)
  File "C:\Users\jaraco\projects\public\cpython\Lib\test\test_support.py", line
1077, in _run_suite
raise TestFailed(err)
test.test_support.TestFailed: multiple errors occurred

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.or

[issue13662] os.listdir bug

2011-12-25 Thread wang

wang  added the comment:

only I double click the script file generate this problem.
in IDE not this problem.

--

___
Python tracker 

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



[issue13662] os.listdir bug

2011-12-25 Thread wang

wang  added the comment:

I mean in IDLE can run ok.
the '\ufeff' is still have.

--

___
Python tracker 

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



[issue13662] os.listdir bug

2011-12-25 Thread wang

wang  added the comment:

I mean in IDLE can run ok.
the '\ufeff' is still have.

--

___
Python tracker 

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



[issue13662] os.listdir bug

2011-12-25 Thread wang

Changes by wang :


--
components: +Windows

___
Python tracker 

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



[issue13662] os.listdir bug

2011-12-25 Thread Ezio Melotti

Ezio Melotti  added the comment:

U+FFEF is a Unicode ZERO WIDTH NO-BREAK SPACE / BYTE ORDER MARK.  I'm not sure 
what is it doing in the file name but this doesn't seem a bug in os.listdir.

--
nosy: +ezio.melotti
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue13662] os.listdir bug

2011-12-25 Thread Ezio Melotti

Ezio Melotti  added the comment:

s/U+FFEF/U+FEFF/
See also http://unicode.org/faq/utf_bom.html#bom1

--

___
Python tracker 

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



[issue13639] UnicodeDecodeError when creating tar.gz with unicode name

2011-12-25 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

As I understand the patched code, it only fixes the issue for unicode names 
that can be latin-1 encoded and that other unicode names will raise the same 
exception with 'latin-1' (or equivalent) substituted for 'ascii'. So it is easy 
for me to anticipate a new issue reporting such someday.

I would prefer a more complete fix. If 3 is easier than 4, fine with me.

--

___
Python tracker 

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



[issue13639] UnicodeDecodeError when creating tar.gz with unicode name

2011-12-25 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I just took a look as the 3.2 tarfile code and see that it always (because 
self.name is always unicode) does the same encoding, with 'replace', 
referencing RFC1952. Although there are a few other differences, they appear 
inconsequential, so that the code otherwise should behave the same. Reading 
further on codec error handling, I gather that my previously understanding was 
off; non-Latin1 chars will just all appear as '?' instead of raising an 
exception. While that is normally useless, it does not matter since the result 
is not used. So I agree to call this fixed.

--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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