MCPcopy Index your code
hub / github.com/python/cpython / __new__

Method __new__

Lib/enum.py:1375–1394  ·  view source on GitHub ↗

values must already be of type `str`

(cls, *values)

Source from the content-addressed store, hash-verified

1373 """
1374
1375 def __new__(cls, *values):
1376 "values must already be of type `str`"
1377 if len(values) > 3:
1378 raise TypeError('too many arguments for str(): %r' % (values, ))
1379 if len(values) == 1:
1380 # it must be a string
1381 if not isinstance(values[0], str):
1382 raise TypeError('%r is not a string' % (values[0], ))
1383 if len(values) >= 2:
1384 # check that encoding argument is a string
1385 if not isinstance(values[1], str):
1386 raise TypeError('encoding must be a string, not %r' % (values[1], ))
1387 if len(values) == 3:
1388 # check that errors argument is a string
1389 if not isinstance(values[2], str):
1390 raise TypeError('errors must be a string, not %r' % (values[2]))
1391 value = str(*values)
1392 member = str.__new__(cls, value)
1393 member._value_ = value
1394 return member
1395
1396 @staticmethod
1397 def _generate_next_value_(name, start, count, last_values):

Callers

nothing calls this directly

Calls 2

strFunction · 0.85
__new__Method · 0.45

Tested by

no test coverage detected