Mercurial > public > mercurial-scm > hg
comparison mercurial/bundle2.py @ 50549:037890ecaff5
safehasattr: pass attribute name as string instead of bytes
This is a step toward replacing `util.safehasattr` usage with plain `hasattr`.
The builtin function behave poorly in Python2 but this was fixed in Python3.
These change are done one by one as they tend to have a small odd to trigger
puzzling breackage.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 02 Feb 2023 17:19:26 +0100 |
parents | f4a540c203d7 |
children | 7200a9d4ea04 |
comparison
equal
deleted
inserted
replaced
50548:b1fb4185e47c | 50549:037890ecaff5 |
---|---|
1232 | 1232 |
1233 Exists to handle the different methods to provide data to a part.""" | 1233 Exists to handle the different methods to provide data to a part.""" |
1234 # we only support fixed size data now. | 1234 # we only support fixed size data now. |
1235 # This will be improved in the future. | 1235 # This will be improved in the future. |
1236 if util.safehasattr(self.data, 'next') or util.safehasattr( | 1236 if util.safehasattr(self.data, 'next') or util.safehasattr( |
1237 self.data, b'__next__' | 1237 self.data, '__next__' |
1238 ): | 1238 ): |
1239 buff = util.chunkbuffer(self.data) | 1239 buff = util.chunkbuffer(self.data) |
1240 chunk = buff.read(preferedchunksize) | 1240 chunk = buff.read(preferedchunksize) |
1241 while chunk: | 1241 while chunk: |
1242 yield chunk | 1242 yield chunk |