[issue23076] list(pathlib.Path().glob("")) fails with IndexError
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 <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
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 "", line 1, in 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 <http://bugs.python.org/issue23076> ___ ___ 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
liu chang added the comment: a simple fix -- keywords: +patch Added file: http://bugs.python.org/file37465/fix-tar-23056.patch ___ Python tracker <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
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 <http://bugs.python.org/issue23056> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23064] pep8 asyncore.py
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 <http://bugs.python.org/issue23064> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com