[MERGE] Repository.iter_files_bytes()
Alexander Belchenko
bialix at ukr.net
Thu Mar 26 09:57:08 GMT 2009
Vincent Ladeuil пишет:
>>>>>> "bialix" == Alexander Belchenko <bialix at ukr.net> writes:
>
> bialix> Robert Collins пишет:
> >> On Wed, 2009-03-25 at 14:16 -0400, Aaron Bentley wrote:
> >>>> === modified file 'bzrlib/revisiontree.py'
> >>>> --- bzrlib/revisiontree.py 2009-03-23 14:59:43 +0000
> >>>> +++ bzrlib/revisiontree.py 2009-03-25 16:27:34 +0000
> >>>> @@ -64,7 +64,8 @@
> >>>> return self._revision_id
> >>>>
> >>>> def get_file_text(self, file_id, path=None):
> >>>> - return list(self.iter_files_bytes([(file_id, None)]))[0][1]
> >>>> + _, content = list(self.iter_files_bytes([(file_id,
> >>> None)]))[0]
> >>>
> >>> I would prefer not to use underscore this way, but I guess there's
> >>> already precedent in the codebase.
> >>
> >> FWIW, I recall seeing comments from Guido that this is approriate.
>
> bialix> The _ interacts horribly with pdb and gettext.
>
> And selftest ! :-)
>
> As seen in https://bugs.launchpad.net/bzr-gtk/+bug/187283
>
> Given that using '_' as an anonymous variable is a common idiom
> in python, this conflicts hard with gettext reserving '_' for its
> private usage by adding it to __global__ so that it can be
> accessed anywhere without importing gettext again.
>
> But doing so is fragile as it means any *apparently* local use of
> '_' will in fact modify the globally gettext installed one.
>
> bzr-gtk addressed the problem in (shameless plug)
> revid:v.ladeuil+lp at free.fr-20080505181646-n95l8ltw2u6jtr26
>
> Since any plugin[1] (in addition to bzrlib itself) can use '_', relying on gettext
> definition of '_' is asking for trouble, the only reliable way to
> be protected against that I could think of was to use a private
> alias for '_' immune to the problem.
>
> Vincent
>
> [1]: I.e. even if bzrlib never uses '_' as an anonymous variable,
> as soon as any plugin uses it (or any python module today or
> tomorrow), you're doomed.
I'm aware about this problem, and in QBzr we don't use _ for gettext stuff :-)
More information about the bazaar
mailing list