Akos Kiss <akosthek...@gmail.com> added the comment:

Re: Eric

I had a code where `'sometemplate'.format()` got a dictionary from outside (as 
a parameter, not from `locals()`), and that dictionary had `None` as a key. 
Actually, I wasn't even aware of that `None` key until I tried to execute the 
same code in PyPy where it failed with a `TypeError`. That's when I started to 
dig down to the root of the incompatibility.

Now, my code has a workaround to have an `if key is not None` filter in the 
comprehension that constructs the dict. (I'm not sure whether it can be called 
a workaround, since this is how it should have been written in the first place. 
It turns out I was just (ab)using an implementation detail / deviation.)

So much about real-world use cases.

There is one more use case that comes to my mind, but it is admittedly 
theoretical (for now, at least). If I ever wanted to patch/wrap/mock 
`str.format` then the wrapped version would behave differently from the 
built-in version (throw an error when the original does not). But this is 
hypothetical at the moment because I "can't set attributes of 
built-in/extension type 'str'" and don't have the time to experiment with 
complex mocking/patching/wrapping approaches.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39694>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to