[Python-checkins] r45862 - in python/trunk: Doc/lib/libcontextlib.tex Doc/ref/ref3.tex Doc/ref/ref7.tex Lib/calendar.py Lib/compiler/pycodegen.py Lib/contextlib.py Lib/decimal.py Lib/dummy_thread.py Lib/test/test_contextlib.py Lib/test/test_with.

Neal Norwitz nnorwitz at gmail.com
Wed May 3 07:56:26 CEST 2006


I wonder if get_manager() would be a better method name.  At least this:

    with decimal.ExtendedContext.get_manager():

reads better to me since context is not duplicated.

n
--

> Modified: python/trunk/Lib/decimal.py
> ==============================================================================
> --- python/trunk/Lib/decimal.py (original)
> +++ python/trunk/Lib/decimal.py Tue May  2 21:47:52 2006
> @@ -2248,7 +2248,7 @@
>          s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']')
>          return ', '.join(s) + ')'
>
> -    def __context__(self):
> +    def context_manager(self):
>          return WithStatementContext(self.copy())
>
>      def clear_flags(self):
>

> Modified: python/trunk/Lib/test/test_contextlib.py
> ==============================================================================
> --- python/trunk/Lib/test/test_contextlib.py    (original)
> +++ python/trunk/Lib/test/test_contextlib.py    Tue May  2 21:47:52 2006
> @@ -341,12 +339,12 @@
>          orig_context = ctx.copy()
>          try:
>              ctx.prec = save_prec = decimal.ExtendedContext.prec + 5
> -            with decimal.ExtendedContext:
> +            with decimal.ExtendedContext.context_manager():
>                  self.assertEqual(decimal.getcontext().prec,
>                                   decimal.ExtendedContext.prec)
>              self.assertEqual(decimal.getcontext().prec, save_prec)
>              try:
> -                with decimal.ExtendedContext:
> +                with decimal.ExtendedContext.context_manager():
>                      self.assertEqual(decimal.getcontext().prec,
>                                       decimal.ExtendedContext.prec)
>                      1/0
>


More information about the Python-checkins mailing list