[issue23076] list(pathlib.Path().glob()) fails with IndexError

2015-01-01 Thread liu chang

liu chang added the comment:

hi pitrou, should we fix it in _make_selector(pattern_parts) function? 
origin code as:

def _make_selector(pattern_parts):
pat = pattern_parts[0]
child_parts = pattern_parts[1:]
if pat == '**':
cls = _RecursiveWildcardSelector
elif '**' in pat:
raise ValueError(Invalid pattern: '**' can only be an entire path 
component)
elif _is_wildcard_pattern(pat):
cls = _WildcardSelector
else:
cls = _PreciseSelector
return cls(pat, child_parts)

Is it a good fix that: check the length of pattern_parts, if its length  2, we 
set pat to empty str, set child_parts to a empty list。

A simple code like:

def _make_selector(pattern_parts):
try:
pat = pattern_parts[0]
child_parts = pattern_parts[1:]
except IndexError:
pat = 
child_parts = []
if pat == '**':
cls = _RecursiveWildcardSelector
elif '**' in pat:
raise ValueError(Invalid pattern: '**' can only be an entire path 
component)
elif _is_wildcard_pattern(pat):
cls = _WildcardSelector
else:
cls = _PreciseSelector
return cls(pat, child_parts)

--

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



[issue23076] path.glob() fails with IndexError

2014-12-17 Thread liu chang

liu chang added the comment:

In[6]: pathlib.Path.glob()
Traceback (most recent call last):
  File 
/home/liuchang/ENV3/lib/python3.4/site-packages/IPython/core/interactiveshell.py,
 line 2883, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
  File ipython-input-6-a6dcf250fe73, line 1, in module
pathlib.Path.glob()
TypeError: glob() missing 1 required positional argument: 'pattern'

the version of my python is 3.4。
I got a TypeError, No IndexError。

--
nosy: +liu chang

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



[issue23064] pep8 asyncore.py

2014-12-16 Thread liu chang

New submission from liu chang:

pep8 Lib/asycore.py.

--
components: Library (Lib)
files: pep8-asyncore.patch
hgrepos: 287
keywords: patch
messages: 232730
nosy: 畅.刘
priority: normal
severity: normal
status: open
title: pep8 asyncore.py
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file37462/pep8-asyncore.patch

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



[issue23056] tarfile raises an exception when reading an empty tar in streaming mode

2014-12-16 Thread liu chang

liu chang added the comment:

2232 def next(self):
2233 Return the next member of the archive as a TarInfo object, when
2234TarFile is opened for reading. Return None if there is no more
2235available.
2236 
2237 self._check(ra)
2238 if self.firstmember is not None:
2239 m = self.firstmember
2240 self.firstmember = None
2241 return m
2242 
2243 # Read the next block.
2244 self.fileobj.seek(self.offset)
2245 tarinfo = None

raise a StreamError at #2244, It should catch this Error and return None. I 
would like to post a patch to fix it.

--
nosy: +liu chang

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



[issue23056] tarfile raises an exception when reading an empty tar in streaming mode

2014-12-16 Thread liu chang

liu chang added the comment:

a simple fix

--
keywords: +patch
Added file: http://bugs.python.org/file37465/fix-tar-23056.patch

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