[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light

python/cpython

nickgaya

Commits on Dec 10, 2020

  1. bpo-34750: [Enum] add `_EnumDict.update()` support (GH-23725)

    This allows easier Enum construction in unusual cases, such as including dynamic member definitions into a class definition:
    
    # created dynamically
    foo_defines = {'FOO_CAT': 'aloof', 'BAR_DOG': 'friendly', 'FOO_HORSE': 'big'}
    
    class Foo(Enum):
        vars().update({
                k: v
                for k, v in foo_defines.items()
                if k.startswith('FOO_')
                })
        def upper(self):
            # example method
            return self.value.upper()

Commits on Dec 9, 2020

  1. bpo-32381: Add _PyRun_AnyFileObject() (GH-23723)

    pymain_run_file() no longer encodes the filename: pass the filename
    as an object to the new _PyRun_AnyFileObject() function.
    
    Add new private functions:
    
    * _PyRun_AnyFileObject()
    * _PyRun_InteractiveLoopObject()
    * _Py_FdIsInteractive()

Commits on Dec 8, 2020

  1. bpo-32381: Fix PyRun_SimpleFileExFlags() encoding (GH-23642)

    Fix encoding name when running a ".pyc" file on Windows:
    PyRun_SimpleFileExFlags() now uses the correct encoding to decode the
    filename.
    
    * Add pyrun_file() subfunction.
    * Add pyrun_simple_file() subfunction.
    * PyRun_SimpleFileExFlags() now calls _Py_fopen_obj() rather than
      _Py_fopen().