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.

Author eric.snow
Recipients Rosuav, eric.snow, methane, rhettinger, serhiy.storchaka, steve.dower
Date 2018-09-20.16:17:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1537460237.94.0.956365154283.issue34320@psf.upfronthosting.co.za>
In-reply-to
Content
FWIW, the PEP 520 example isn't exactly right.  PEP 520 is about the class definition namespace, not the namespace object passed to type().  That always does the right thing, since the default class definition namespace is dict (which happens to be ordered in 3.6+).

That said, a test that explicitly calls type() with an OrderedDict, as you have shown, is still a good idea since type() always changes the namespace to a dict.

Perhaps another good test of the same thing would be with a metaclass that returns an OrderedDict from __prepare__():

  class Meta(type):
      @classmethod
      def __prepare__(meta, name, bases, **kwargs):
          return OrderedDict()

  class Spam(metaclass=Meta):
      a = 1
      b = 2
      locals().move_to_end('a')

  Spam.__dict__

Just keep in mind that neither of those is specific to PEP 520.
History
Date User Action Args
2018-09-20 16:17:17eric.snowsetrecipients: + eric.snow, rhettinger, methane, Rosuav, serhiy.storchaka, steve.dower
2018-09-20 16:17:17eric.snowsetmessageid: <1537460237.94.0.956365154283.issue34320@psf.upfronthosting.co.za>
2018-09-20 16:17:17eric.snowlinkissue34320 messages
2018-09-20 16:17:17eric.snowcreate