This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: match object generated by re.finditer cannot call groups() on mac
Type: compile error Stage:
Components: macOS, Regular Expressions Versions: Python 2.7
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: ezio.melotti, leiju, mrabarnett, ronaldoussoren
Priority: normal Keywords:

Created on 2014-08-22 19:15 by leiju, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg225697 - (view) Author: (leiju) Date: 2014-08-22 19:15
See the simple test below:


failed on 13.3.0 Darwin Kernel Version 13.3.0, Python 2.7.8:
============================================================

Python 2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 21:07:35) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 
>>> 
>>> import re
>>> 
>>> p = '(abc)|(def)|(xyz)'
>>> s = 'abcdefxyz'
>>> 
>>> 
>>> for s in re.finditer(p, s): print s.groups()
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 186, in finditer
    return _compile(pattern, flags).finditer(string)
TypeError: expected string or buffer
>>



same test succeeds on Windows 7 professional:
============================================


Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> p = '(abc)|(def)|(xyz)'
>>> s = 'abcdefxyz'
>>>
>>> import re
>>>
>>> for x in re.finditer(p, s): print x.groups()
...
('abc', None, None)
(None, 'def', None)
(None, None, 'xyz')
>>>
>>>
>>>
>>>




same test succeeds on freedbsd 7.4. Python 2.7.1:
=================================================



Python 2.7.1 (r271:86832, Jan 31 2011, 17:18:31) 
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd7
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> p = '(abc)|(def)|(xyz)'
>>> s = 'abcdefxyz'
>>> for s in re.finditer(p, s): print s.groups()
... 
('abc', None, None)
(None, 'def', None)
(None, None, 'xyz')
>>> 
>>> 
>>> 
>>>
msg225699 - (view) Author: (leiju) Date: 2014-08-22 19:34
closed as cannot reproduce it anymore:


Python 2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 21:07:35) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 
>>> 
>>> 
>>> import re
>>> p = '(abc)|(def)|(xyz)'
>>> s = 'abcdefxyz'
>>> 
>>> for s in re.finditer(p, s): print s.groups()
... 
('abc', None, None)
(None, 'def', None)
(None, None, 'xyz')
>>> 
>>> 
>>> 
>>>
History
Date User Action Args
2022-04-11 14:58:07adminsetgithub: 66450
2014-08-22 19:34:38leijusetstatus: open -> closed
resolution: works for me
messages: + msg225699
2014-08-22 19:15:49leijucreate